You could catch the error through
void setup() {
try {
// Whatever your code in setup is
}
catch (Exception err) {
println(err);
exit();
}
}
void draw() {
try {
// Whatever your code in draw is
}
catch (Exception err) {
println(err);
exit();
}
}
try … catch blocks.
EDIT: Added semicolons