<s> from __future__ import absolute_import , unicode_literals , print_function , division <EOL> from flask import Blueprint , jsonify <EOL> from werkzeug . exceptions import HTTPException , default_exceptions <EOL> from restfulgit . utils . cors import corsify <EOL> def register_general_error_handler ( blueprint_or_app , handler ) : <EOL> error_codes = default_exceptions . keys ( ) <EOL> if isinstance ( blueprint_or_app , Blueprint ) : <EOL> error_codes . remove ( <NUM_LIT> ) <EOL> for err_code in error_codes : <EOL> blueprint_or_app . errorhandler ( err_code ) ( handler ) <EOL> @ corsify <EOL> def json_error_page ( error ) : <EOL> err_msg = error . description if isinstance ( error , HTTPException ) else unicode ( error ) <EOL> resp = jsonify ( { '<STR_LIT:error>' : err_msg } ) <EOL> resp . status_code = ( error . code if isinstance ( error , HTTPException ) else <NUM_LIT> ) <EOL> return resp </s>
