abstracted error handling