---
schema_version: "1"
id: 552d76ff9543fa3ea1211fea08d4db7d4c7720a39700715de07b542c9998eb19
title: APIkit for OData v4 Error Handling Reference
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/apikit/latest/apikit-odatav4-error-handling-reference.md
canonical_url: https://docs.mulesoft.com/apikit/latest/apikit-odatav4-error-handling-reference
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 64926ee1ac51181f42046b6537da4587c2702f053079ee429986590a61acb891
description: MuleSoft Documentation Site
release: 4.x
latest: true
---
---
product: APIkit
version: 4.x
is-latest-version: true
---

# APIkit for OData v4 Error Handling Reference

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

APIkit for OData v4 maps routing, parsing, serialization, and expansion failures to typed
`APIKIT-ODATA` errors you handle in Mule. Use the error catalog and scaffolded handler in this
reference to interpret failures and return consistent OData error payloads.

## Error Types

APIkit for OData v4 defines error types for common OData processing failures:

<table><colgroup><col> <col></colgroup><thead><tr><th>Error Type</th><th>Description</th></tr></thead><tbody><tr><td><p>APIKIT-ODATA:NOT_IMPLEMENTED</p></td><td><p>Requested service, feature, or operation not implemented</p></td></tr><tr><td><p>APIKIT-ODATA:MALFORMED_URI</p></td><td><p>Invalid request URI</p></td></tr><tr><td><p>APIKIT-ODATA:MALFORMED_SEARCH</p></td><td><p>Invalid request <code>$search</code> expression in URI</p></td></tr><tr><td><p>APIKIT-ODATA:SERIALIZATION</p></td><td><p>Generic error for serialization issues</p></td></tr><tr><td><p>APIKIT-ODATA:DESERIALIZATION</p></td><td><p>Generic error for deserialization issues</p></td></tr><tr><td><p>APIKIT-ODATA:TRANSFORMATION</p></td><td><p>Generic error for issues related to URI to SQL transformations</p></td></tr><tr><td><p>APIKIT-ODATA:INTERNAL_SERVER_ERROR</p></td><td><p>Generic error for internal server issues</p></td></tr><tr><td><p>APIKIT-ODATA:NOT_FOUND</p></td><td><p>Generic error for not found</p></td></tr><tr><td><p>APIKIT-ODATA:EXPANSION</p></td><td><p>Generic error for issues during expansion</p></td></tr></tbody></table>

## Error Handling

APIkit for OData v4 scaffolder generates an error handler with a single `On Error Propagate` catch
that serves as a generalized error formatter.

```xml
...
    <error-handler name="Error_Handler">
      <on-error-propagate name="On_Error_Propagate" enableNotifications="true" logException="true" type="ANY">
        <ee:transform>
          <ee:message>
            <ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
	error: {
		code: error.errorMessage.payload.code default "UNKNOWN",
		message: error.errorMessage.payload.message default error.description,
		target: error.errorMessage.payload.target,
		details: error.errorMessage.payload.details default [{code: "UNKNOWN", message: error.detailedDescription, target: null}],
		innererror: error.errorMessage.payload.innerError default error.childErrors
	}
}]]></ee:set-payload>
          </ee:message>
          <ee:variables>
            <ee:set-variable variableName="statusCode"><![CDATA[error.errorMessage.payload.statusCode default 500]]></ee:set-variable>
          </ee:variables>
        </ee:transform>
      </on-error-propagate>
    </error-handler>
...
```

## See Also

- [Error Handlers](https://docs.mulesoft.com/mule-runtime/latest/error-handling)
