atk-sc3
atk-sc3 copied to clipboard
Error throwing
In a number of places (example) in Atk there is a convention attempting a cleaner error reporting:
"error message".error;
this.halt;
This results in an error message without the call stack (which is nice) and seemingly correct behavior (execution stops). Such non-error errors, however, are impossible to catch with try({}, {})
:
(
try({
"error message".error;
"still running".postln;
this.halt;
}, {
"caught?".postln;
})
) // first block runs entirely
(
try({
Error("error message").throw;
"still running".postln;
}, { |err|
"caught:".postln;
err.errorString.postln; //optionally post an error
})
) //execution stops at error, which is then caught
Maybe for the sake of compatibility it would be reasonable to revert back to throwing errors with the call stack (Error("message").throw
)? Again, this is only an issue if the user tries to catch Atk errors.
Relatedly, I think we'd want to consider reviewing all error throwing within the complete codebase.