middleware (process_exception)