return error object on error (since core doesn't always expect exceptions