-
Notifications
You must be signed in to change notification settings - Fork 8
[CORE-7914] Log an unhandled exception or a user abort before the computation ends #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7324698 to
366add1
Compare
| ask = lift ask | ||
| local = mapLogT . local | ||
|
|
||
| -- | Run a 'LogT' computation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the haddock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I'm stupid 😬
log-base/src/Log/Monad.hs
Outdated
| import Control.Monad.Writer.Class | ||
| import Data.Aeson | ||
| import Data.Text (Text) | ||
| import Data.Text (Text, pack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need pack, aeson handles string conversions itself.
log-base/src/Log/Monad.hs
Outdated
| logAttention "Uncaught exception raised" $ object ["error" .= (pack . show $ e)] | ||
| throwM e | ||
| ExitCaseAbort -> | ||
| logAttention_ "Process was aborted manually" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExitCaseAbort does not mean process was aborted, it means the computation was aborted with means other than runtime exception (like the error from ExceptT if the stack happens to have it).
|
Please check that it logs the exception when cron exits with the exception (and provide associated kontrakcja PR). |
|
You were right to ask, because it doesn't work :( |
|
All right, finally manage to make it work.
|
c84f054 to
c75ec4f
Compare
|
OK, here is a (hopefully) final version using |
Anything that I can help with for that particular issue? |
arybczak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks 👍
Also needs a version bump to 0.13.0.0 and a changelog entry.
log-base/src/Log/Monad.hs
Outdated
| runLogT component logger maxLogLevel m = runReaderT | ||
| (unLogT $ liftedCatch m (\(SomeException e) -> do | ||
| logAttention "Uncaught exception" $ object ["error" .= show e] | ||
| E.throw e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| E.throw e) | |
| liftBase $ E.throwIO e) |
@theophile-scrive You can add |
|
Please don't merge yet, I'm wondering about this comment. |
Rather than patching runLogT directly, add a composable utility
arybczak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix missing dots at the end of sentences.
log-base/log-base.cabal
Outdated
| cabal-version: 3.0 | ||
| name: log-base | ||
| version: 0.12.0.1 | ||
| version: 0.13.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be 0.12.1.0 now since we're not changing runLogT.
log-base/CHANGELOG.md
Outdated
| @@ -1,3 +1,6 @@ | |||
| # log-base-0.13.0.0 (2025-06-23) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # log-base-0.13.0.0 (2025-06-23) | |
| # log-base-0.12.1.0 (2025-??-??) |
I'll set the date when a release is made.
log-base/src/Log/Monad.hs
Outdated
| , runLogT | ||
| , mapLogT | ||
| , logMessageIO | ||
| , logExceptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put it after runLogT on the list so it matches place in the code.
log-base/src/Log/Monad.hs
Outdated
| } -- We can't do synchronisation here, since 'runLogT' can be invoked | ||
| -- quite often from the application (e.g. on every request). | ||
|
|
||
| -- | Unsure uncaught exceptions get logged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure
| http-client, | ||
| http-types, | ||
| log-base >= 0.10 && <0.13, | ||
| log-base >= 0.10 && <0.14, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this now (same below).
00ae1a2 to
c8f1072
Compare
|
Applied your suggestions and added the missing dots. |
arybczak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
Ensures that uncaught exception leaves a log, so it's easier to know what happened and debuggers are not left in the dark. Unfortunately, this adds a constraint to the underlying monad.