Make on_error follow Flask format