I would suggest a different approach:
- define a member variable $errorHandler that contains a callback function.
- per default, this would throw a RuntimeException
- provide a setter for the callback function
- for batch mode, set it to a closure that odes nothing, or just logs output
That's clearer and more flexible, and it allows you to use the maintenancescript's output) function to report issues to the user.