type_error - BenjaminFourmaux/ServiceDown-api Wiki

Type : Error

An error

Fields

Name Description Type
error Body of error object
error_code Error code id int
error_name Error name string
error_message Description about the error string (text)
trace Error event id, use it for contacting assistance. (useless now, just for fun) string (format : sd_trace-[event_id])

Exemple

An example of an error when to get not available country

{
    "error": {
        "error_code": 102,
        "error_name": "country_not_available",
        "error_message": "This country is not available",
        "trace": "sd_trace-22082001",
    },
}

Catch error

For detect if response has an error, you can find if http response has error field in json. if response contain object 'error' then is an error

response = requests.get('https://api.service-down.com/country/400')

if 'error' in response.to_json():
	raise Error(response.to_json())
else:
	# continue treatment

List of errors

Code Name Message HTTP Code Cause
---- Generic ---- ---- ----
2 method_not_allowed Method: {method-name} not allowed on node: {node-path} 405 Your method request is not allowed on the node
3 serializer_no_field No field: {requested-field_name} in serializer: {serializer_name} 400 You trying to access to a non existing field
4 paging_index_out_of_range Paging index: {index} out of range ({start_index}, {end_index}) 400 Your page index is out of paging range
---- Country ---- ---- ----
101 country_not_found Country id: {country_id} not found 404 You want to access a non-existing country
102 country_not_available This country is not available 403 The country has no service or is disabled
103 country_shortname_not_exist Country shortname: '{shortname}' not exist 404 You try to get Country by his shortname
----- Service ---- ---- ----
201 service_not_found Service id: {service_id} not found 404 You want to access a non-existing service
202 service_not_in_country Service: {service_id} not available in Country: {country_id} 404 You trying to get service from country, but this service is not available in this country
---- Search ---- ---- ----
401 missing_query_parameter Missing query parameter : 'q' 400 You forget th query parameter in url