Class: ODataExceptionFilter
Defined in: response/odata-exception.filter.ts:50
NestJS exception filter that converts all caught exceptions into OData v4 error format.
Per D-09: all errors are formatted as { error: { code, message, details } }. Per D-11, T-03-08: never includes stack traces or internal server details.
The application's errorMapper (ODataModule.forRoot() option) runs first and may map any exception to an OData error (code, message, status, target, details). When it returns undefined, the default mapping applies:
- ODataParseError -> HTTP 400, code 'BadRequest', user message
- ODataValidationError -> HTTP 400, code 'BadRequest', user message
- HttpException -> uses exception's HTTP status code, generic OData code
- All others -> HTTP 500, code 'InternalServerError', generic message (no details leaked)
Every error response carries Content-Language (OData-Protocol 4.01 §9.4): the mapping's language, else the errorLanguage module option, else en.
It also answers the internal ODataEmptyResponse signal (304 Not Modified, 204 for Prefer: return=minimal) with an empty response; that signal is not an error.
Applied by the OData route decorators (@ODataGet, @ODataPost, …), to $metadata and to $batch. Other routes, including plain Nest routes on an @ODataController class, keep the application's own (global) filters; add @UseFilters(ODataExceptionFilter) to opt one in.
Zero TypeORM imports — per PKG-01 architecture constraint.
Implements
ExceptionFilter
Constructors
Constructor
new ODataExceptionFilter(
options?):ODataExceptionFilter
Defined in: response/odata-exception.filter.ts:51
Parameters
options?
Partial<Pick<ODataModuleResolvedOptions, "errorMapper" | "errorLanguage">>
Returns
ODataExceptionFilter
Methods
catch()
catch(
exception,host):void
Defined in: response/odata-exception.filter.ts:59
Method to implement a custom exception filter.
Parameters
exception
unknown
the class of the exception being handled
host
ArgumentsHost
used to access an array of arguments for the in-flight request
Returns
void
Implementation of
ExceptionFilter.catch