Add option to handle errors as exceptions