atk-sc3 icon indicating copy to clipboard operation
atk-sc3 copied to clipboard

Error throwing

Open dyfer opened this issue 5 years ago • 1 comments

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.

dyfer avatar Dec 20 '19 00:12 dyfer

Relatedly, I think we'd want to consider reviewing all error throwing within the complete codebase.

joslloand avatar Jan 15 '21 20:01 joslloand