Errors
Error Responses
Fail Fast
TruckMate’s REST APIs follow the fail fast principle. The API Server makes use of the OpenAPI specification to validate input prior to moving onto database and business logic validations. If any failures are found no further processing will be performed.
1. Path Validation
Ensure that the URL path of the API request is correctly formatted, meeting the expectations of the API endpoint.
2. Authentication and Authorization
Verify the identity of the client making the API request, ensuring the necessary credentials allow to access the requested resource. Ensure the authenticated client has the appropriate permissions for the requested endpoint and method.
3. Query String Validation
All query string parameters sent with the request will be validated to ensure that the endpoint supports the parameter, and the parameter supports the value.
4. OpenAPI Schema Validation
Before processing, an initial introspection will be conducted to consolidate any OpenAPI-related errors. If the request deviates from the corresponding OpenAPI specification, a comprehensive summary of all problems will be included in the response body as part of the errors array.
5. Business Logic and Database Value Validations
Business logic errors will be return individually. Business logic errors often require SQL statements to be run, in favor of performance and to minimize the SQL statements run, the first error found will end processing and return the error response to the user.
Error Messages
Errors are returned using standard HTTP Response Codes. Any additional information pertaining to the error will be included in the response body. Please see below table containing the list of currently used error codes and their associated messages:
Status Code | Error Code | Associated Message |
---|---|---|
301 | movedPermanently | The endpoint has been moved permanently. Please refer to the OpenAPI Specification for a list of supported methods and endpoints. |
401 | unauthorized | The supplied authentication credentials are not valid. |
403 | forbidden | The supplied authentication credentials are not sufficient to access the resource, or perform the requested operation. |
404 | resourceNotFound | Not found. The server has not found anything matching the Request-URI. |
405 | methodNotAllowed | Method not allowed. Please refer to the OpenAPI Specification for a list of supported methods and endpoints. |
409 | resourceConflict | The supplied authentication credentials are not valid. |
420 | licenseNotAvailable | License not available. |
429 | tooManyRequests | Too many requests. |
500 | serverError | Server error. |
400 | belowMinValue | {field} cannot be less than the minimum value of {value}. |
400 | exceedsMaxLength | {field} is expected to not exceed maximum length of {value} character(s). |
400 | invalidJsonArray | {field} is expected to be a valid JSON array. |
400 | invalidJsonObject | {field} is expected to be a valid JSON object. |
400 | noValidFields | No valid fields sent with the request. Please refer to the OpenAPI Specification for a list of supported fields. |
400 | invalidJsonValue | {field} is expected to satisfy one of the following conditions: {oneOf conditions}. |
400 | invalidDateTime | {field} is expected to be a valid datetime string (yyyy-MM-ddThh:mm). |
400 | invalidDate | {field} is expected to be a valid date string (yyyy-MM-dd). |
400 | invalidTime | {field} is expected to be a valid time string (hh). |
400 | invalidPattern | {field} does not match the pattern defined in the OpenAPI specification. |
400 | invalidFormat | {field} is expected to be in the valid format. |
400 | invalidDouble | {field} is expected to be a valid double. |
400 | invalidEnum | {field} is expected to be a value of {enum values}. |
400 | invalidInteger | {field} is expected to be a valid integer. |
400 | invalidString | {field} is expected to be a valid string. |
400 | missingRequiredField | {field} is a required field. |
400 | invalidQueryParameter | Query parameter {parameter} is not supported for this endpoint. |
400 | invalidDBValue | {field} is not a valid {label}. |
400 | invalidBusinessLogic | This will be unique depending on the business use case, this could be related to configuration options or other logic. |