Flush stderr after printing exception in the default error handler.
Added a function for handling errors coming externally.