Skip to content
module@warp-drive/legacy/adapter/error @legacy

Variable ForbiddenError

ts
ForbiddenError: AdapterRequestErrorConstructor<ForbiddenError>;

Defined in: warp-drive-packages/legacy/src/adapter/error.ts:384

A ForbiddenError equates to an HTTP 403 Forbidden response status. It is used by an adapter to signal that a request to the external API was valid but the server is refusing to respond to it. If authorization was provided and is valid, then the authenticated user does not have the necessary permissions for the request.

Unlike an UnauthorizedError, retrying the request with different credentials will not help; the currently authenticated user simply lacks permission. An example use case would be to show the user a "you don't have access to this" message rather than redirecting them to log in:

app/routes/application.js
js
import { ForbiddenError } from '@warp-drive/legacy/adapter/error';

export default class ApplicationRoute extends Route {
  @action
  error(error, transition) {
    if (error instanceof ForbiddenError) {
      this.transitionTo('forbidden');
      return;
    }

    // ...other error handling logic
  }
}

Released under the MIT License.