Replies: 1 comment 1 reply
-
|
I'm indeed not a big fan as it adds overhead without really helping in the server. If it is important that the error is logged, I would also do it in the class where the error happens for clarity in the logs. For some classes it is fine that an error happens and this would pollute the logs in those cases. Also of note is that in the next major release, the utility handlers are being moved to an external library: b9616b3. This major release will probably not be soon though. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Yesterday, I spent a significant amount of time tracking down a bug in one of CSS
MetadataWriterinstances .I set a debugger breakpoint in my editor at the point where I thought an error was being thrown, but I was able to "Next Step" past that code without entering the expected "catch" block. After stepping through the code for a while, I unexpectedly ended up in a higher-level catch block.
This was confusing—why wasn't the buggy part triggering the catch, and why did the catch only execute after processing code that appeared safe?
After several hours, I realized that all
MetadataWriterinstances are invoked in aParallelHandlerusingPromise.allas shown:If one of the handlers throws an error, the implementation executes all the handlers and waits for every promise to resolve before throwing the error. That’s why, in the debugger, I wasn’t redirected to a catch block immediately after the suspicious code (the debugger jumped to the next handler) and only reached the catch block after all promises resolved and the error was thrown by the last handler. This behavior now makes sense, although it was difficult to diagnose at first.
I’m concerned that if this happens again, I might forget the details—and other developers might face the same issue.
A solution that could have save me time is to wrap the
Promise.allin a try-catch block:With the above, the developer is cleary informed which handler caused the error. Which drastically help scoping the bug in contrast to an error from
HandlerServerConfigurator.ts@joachimvh, I understand if you dont want to add try-catch blocks everywhere as it might seem messy, but I believe this change could really help with debugging. Would you be open to a PR implementing this improvement?
Beta Was this translation helpful? Give feedback.
All reactions