Added make_error_object function, if error caused.