<s> '''<STR_LIT>''' <EOL> import copy <EOL> import httplib as http <EOL> from flask import request <EOL> class FrameworkError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class HTTPError ( FrameworkError ) : <EOL> error_msgs = { <EOL> http . BAD_REQUEST : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> } , <EOL> http . UNAUTHORIZED : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> http . FORBIDDEN : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> } , <EOL> http . NOT_FOUND : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> } , <EOL> http . GONE : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> } , <EOL> http . SERVICE_UNAVAILABLE : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> } , <EOL> } <EOL> def __init__ ( self , code , message = None , redirect_url = None , data = None ) : <EOL> super ( HTTPError , self ) . __init__ ( message ) <EOL> self . code = code <EOL> self . redirect_url = redirect_url <EOL> self . data = data or { } <EOL> try : <EOL> self . referrer = request . referrer <EOL> except RuntimeError : <EOL> self . referrer = None <EOL> def __repr__ ( self ) : <EOL> class_name = self . __class__ . __name__ <EOL> return '<STR_LIT>' . format ( <EOL> ClassName = class_name , <EOL> code = self . code , <EOL> data = self . to_data ( ) , <EOL> ) <EOL> def __str__ ( self ) : <EOL> return repr ( self ) <EOL> def to_data ( self ) : <EOL> data = copy . deepcopy ( self . data ) <EOL> if self . code in self . error_msgs : <EOL> data = { <EOL> '<STR_LIT>' : self . error_msgs [ self . code ] [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : self . error_msgs [ self . code ] [ '<STR_LIT>' ] <EOL> } <EOL> else : <EOL> data [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> data [ '<STR_LIT>' ] = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> data . update ( self . data ) <EOL> data [ '<STR_LIT:code>' ] = self . code <EOL> data [ '<STR_LIT>' ] = self . referrer <EOL> return data <EOL> class PermissionsError ( FrameworkError ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
