Add a convenient way of obtaining error object