Skip to main content

StrapiApiError

Upgather SDK


Upgather SDK / StrapiApiError

Class: StrapiApiError

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

Parameters​

message​

string

response​

ApiResponse

Returns​

StrapiApiError

Overrides​

Error.constructor

Properties​

response​

readonly response: ApiResponse

The full ApiResponse object


responseBody​

readonly responseBody: unknown

The full response body from Strapi


statusCode​

readonly statusCode: number

HTTP status code from the response

Accessors​

validationErrors​

Get Signature​

get validationErrors(): null | object[]

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[]