Skip to content
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

Rule request - Blocks that are not affected by BLOCK-LEVEL ON ERROR UNDO, THROW need error handling #1073

Open
movedoa opened this issue Sep 27, 2023 · 3 comments

Comments

@movedoa
Copy link

movedoa commented Sep 27, 2023

There are blocks that are not effected by BLOCK-LEVEL ON ERROR UNDO, THROW.
https://docs.progress.com/bundle/openedge-abl-error-handling-122/page/BLOCK-LEVEL-ON-ERROR-UNDO-THROW-statement.html

A rule that checks if every DO and DO WHILE block has an error handling directive and every Destructor and Event Method (every method that is subscribed to something) has a catch would help to deal with unexpected errors in the code.

The ABL Events are a bit of a special case since if the Publish comes from the AVM, the error is thrown to the publish, which is fine.
But if you subscribe to anything in the .NET runtime (a winforms control for example), the error is still raised in the normal way, the only way to handle that is a catch in the subscribed method.
https://docs.progress.com/bundle/openedge-oo-abl-develop-applications/page/Raise-errors-within-a-class-event-handler.html

A classic example of this problem is a session that runs in batch mode and has some error in, lets say, the destructor.
Without a catch ther error message is piped to stdout (maybe a terminal window, maybe a log file) but all you get ist "Lead attributes in a chained-attribute expression" without a stack or any additional infos.

This is especially fun with bugs that only appear once a month under unknown conditions.

@movedoa movedoa changed the title Rule request - Blocks that are not affected by BLOCK-LEVEL ON ERROR UNDO, THROW need to have a catch Rule request - Blocks that are not affected by BLOCK-LEVEL ON ERROR UNDO, THROW need to error handling Oct 4, 2023
@movedoa movedoa changed the title Rule request - Blocks that are not affected by BLOCK-LEVEL ON ERROR UNDO, THROW need to error handling Rule request - Blocks that are not affected by BLOCK-LEVEL ON ERROR UNDO, THROW need error handling Oct 4, 2023
@movedoa
Copy link
Author

movedoa commented Oct 9, 2024

Got bitten by a variation of this again today.
The error message we saw was a subsequent error in a completely different source file because a DO ON ERROR UNDO, LEAVE block without at CATCH statement swallowed the original error.

@gquerret
Copy link
Contributor

gquerret commented Oct 9, 2024

While reporting every DO and DO WHILE is possible, the number of FP (or cases where you don't know what to do with the error) would be way too high. Destructors and events are more reasonable targets.

@movedoa
Copy link
Author

movedoa commented Oct 10, 2024

I understand that the DO blocks would create a lot of issues depending on coding style but for us it would still be very helpful i think.
A DO block without a UNDO, THROW should always have a CATCH in our code base to detect unexpected errors or to at least explicitely ignore the error.
Since we compile with -undothrow 2, this would give us realiable stack traces even in batch mode and would save us a lot of detective work to hunt down issues.

So maybe this could be an opt in option in the rule? :)
Unless there is some technical reason this can't be checked reliably?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants