diff options
| author | Dan Engelbrecht <[email protected]> | 2024-04-04 14:32:40 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-04-04 14:32:40 +0200 |
| commit | 12b7bf1c16f671c83840961c37a339141a7ffbb3 (patch) | |
| tree | 3c503e6e1cd4d53b87c1baebcf9286ca8b72db06 /src/zencore/jobqueue.cpp | |
| parent | hardening parsepackagemessage (#38) (diff) | |
| download | zen-12b7bf1c16f671c83840961c37a339141a7ffbb3.tar.xz zen-12b7bf1c16f671c83840961c37a339141a7ffbb3.zip | |
improved assert (#37)
- Improvement: Add file and line to ASSERT exceptions
- Improvement: Catch call stack when throwing assert exceptions and log/output call stack at important places to provide more context to caller
Diffstat (limited to 'src/zencore/jobqueue.cpp')
| -rw-r--r-- | src/zencore/jobqueue.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/zencore/jobqueue.cpp b/src/zencore/jobqueue.cpp index 86c08cda9..d26d0dd1e 100644 --- a/src/zencore/jobqueue.cpp +++ b/src/zencore/jobqueue.cpp @@ -69,7 +69,7 @@ public: Stop(); } } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_WARN("Failed shutting down jobqueue. Reason: '{}'", Ex.what()); } @@ -106,7 +106,7 @@ public: }); return {.Id = NewJobId}; } - catch (std::exception& Ex) + catch (const std::exception& Ex) { WorkerCounter.CountDown(); QueueLock.WithExclusiveLock([&]() { @@ -359,7 +359,18 @@ public: CompletedJobs.insert_or_assign(CurrentJob->Id.Id, std::move(CurrentJob)); }); } - catch (std::exception& Ex) + catch (const AssertException& Ex) + { + ZEN_DEBUG("Background job {}:'{}' asserted. Reason: {}", CurrentJob->Id.Id, CurrentJob->Name, Ex.FullDescription()); + QueueLock.WithExclusiveLock([&]() { + CurrentJob->State.AbortReason = Ex.FullDescription(); + CurrentJob->EndTick = JobClock::Now(); + CurrentJob->WorkerThreadId = 0; + RunningJobs.erase(CurrentJob->Id.Id); + AbortedJobs.insert_or_assign(CurrentJob->Id.Id, std::move(CurrentJob)); + }); + } + catch (const std::exception& Ex) { ZEN_DEBUG("Background job {}:'{}' aborted. Reason: '{}'", CurrentJob->Id.Id, CurrentJob->Name, Ex.what()); QueueLock.WithExclusiveLock([&]() { |