<s> from uuid import uuid4 <EOL> class BaseError ( Exception ) : <EOL> @ property <EOL> def data ( self ) : <EOL> return { <EOL> '<STR_LIT>' : [ { <EOL> '<STR_LIT:id>' : uuid4 ( ) , <EOL> '<STR_LIT:code>' : self . code , <EOL> '<STR_LIT:status>' : self . status_code , <EOL> '<STR_LIT:title>' : self . title , <EOL> '<STR_LIT>' : self . detail <EOL> } ] <EOL> } <EOL> class BadRequestError ( BaseError ) : <EOL> title = '<STR_LIT>' <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> def __init__ ( self , detail ) : <EOL> self . detail = detail <EOL> class NotAnAttributeError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , model , key ) : <EOL> tmpl = '<STR_LIT>' <EOL> self . detail = tmpl . format ( model . __jsonapi_type__ , key ) <EOL> class NotSortableError ( BaseError ) : <EOL> title = '<STR_LIT>' <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> def __init__ ( self , model , attr_name ) : <EOL> tmpl = '<STR_LIT>' <EOL> self . detail = tmpl . format ( model . __jsonapi_type__ , attr_name ) <EOL> class PermissionDeniedError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , permission , model , instance = None , field = None ) : <EOL> tmpl = '<STR_LIT>' <EOL> self . detail = tmpl . format ( permission . name , model . __jsonapi_type__ ) <EOL> if instance is not None : <EOL> self . detail += '<STR_LIT:.>' + str ( instance . id ) <EOL> if field is not None : <EOL> self . detail += '<STR_LIT:.>' + field <EOL> class InvalidTypeForEndpointError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , expected , got ) : <EOL> self . detail = '<STR_LIT>' . format ( expected , got ) <EOL> class MissingTypeError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> detail = '<STR_LIT>' <EOL> class MissingContentTypeError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> detail = '<STR_LIT>' <EOL> class ValidationError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , detail ) : <EOL> self . detail = detail <EOL> class ResourceNotFoundError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , model , instance ) : <EOL> self . detail = '<STR_LIT>' . format ( model , instance ) <EOL> class RelatedResourceNotFoundError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , api_type , obj_id ) : <EOL> tmpl = '<STR_LIT>' <EOL> self . detail = tmpl . format ( api_type , obj_id ) <EOL> class RelationshipNotFoundError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , model , instance , key ) : <EOL> self . detail = '<STR_LIT>' . format ( model , instance , key ) <EOL> class ToManyExpectedError ( BaseError ) : <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> def __init__ ( self , model , instance , relationship ) : <EOL> self . detail = '<STR_LIT>' . format ( <EOL> model . __jsonapi_type__ , instance . id , relationship . key ) <EOL> class ResourceTypeNotFoundError ( BaseError ) : <EOL> title = '<STR_LIT>' <EOL> status_code = <NUM_LIT> <EOL> code = '<STR_LIT>' <EOL> def __init__ ( self , api_type ) : <EOL> tmpl = '<STR_LIT>' '<STR_LIT>' <EOL> self . detail = tmpl . format ( api_type ) </s>
