Added getError function to get the whole error object.