return data.error as an error object, not as string