StrapiApiError
Upgather SDK / StrapiApiError
Class: StrapiApiError
Defined in: lib/types/StrapiApiError.ts:21
Error thrown when a Strapi API request fails. Preserves the full response body so callers can extract structured validation errors from Strapi.
Example
try {
await strapiService.type('Sponsor').create({ name: 'Acme' }, { status: 'published' });
} catch (err) {
if (err instanceof StrapiApiError) {
console.log(err.statusCode); // 400
console.log(err.responseBody); // { data: null, error: { status: 400, name: 'ValidationError', ... } }
console.log(err.validationErrors); // [{ path: ['name'], message: 'This attribute must be unique' }]
}
}
Extends
Error
Constructors
new StrapiApiError()
new StrapiApiError(
message,response):StrapiApiError
Defined in: lib/types/StrapiApiError.ts:31
Parameters
message
string
response
Returns
Overrides
Error.constructor
Properties
response
readonlyresponse:ApiResponse
Defined in: lib/types/StrapiApiError.ts:29
The full ApiResponse object
responseBody
readonlyresponseBody:unknown
Defined in: lib/types/StrapiApiError.ts:26
The full response body from Strapi
statusCode
readonlystatusCode:number
Defined in: lib/types/StrapiApiError.ts:23
HTTP status code from the response
Accessors
validationErrors
Get Signature
get validationErrors():
null|object[]
Defined in: lib/types/StrapiApiError.ts:44
Extract Strapi v5 validation error details if present. Returns an array of field-level errors, or null if the response is not a validation error.
Returns
null | object[]