Error Handling

Original Django Rest Framework has been modified a bit for consistency and extended to include error codes.

Expected http status codes are 404 and 400. 400 response details are presented below:

General / Non Field Errors

A response for a single error would look like the following:

{
    "non_field_errors": [       
        "Error message"    
    ],
        "error_codes": [        
            "invalid"    
    ]
}

Multiple errors can be provided under non_field_errors key, for example.:

{    
    "non_field_errors": [        
        "Error message",        
        "Another error"    
    ],    
    "error_codes": [ 
        "invalid",        
        "invalid"    
    ]
}

Field Errors

Errors, associated with the fields, will be returned as a mapping:

And of course can contain multiple messages for a single field:

Any exceptions to these rules should be treated as bugs and reported.

Last updated