allow passing in an error handler, or allow system-defined handler