Skip to content

Documentation / @ember-data/adapter / error / NotFoundError

Defined in: packages/adapter/src/error.js:309

A NotFoundError equates to a HTTP 404 Not Found response status. It is used by an adapter to signal that a request to the external API was rejected because the resource could not be found on the API.

An example use case would be to detect if the user has entered a route for a specific model that does not exist. For example:

app/routes/post.js
js
import { NotFoundError } from '@ember-data/adapter/error';

export default class PostRoute extends Route {
  @service store;
  model(params) {
    return this.store.findRecord('post', params.post_id);
  }
  @action
  error(error, transition) {
    if (error instanceof NotFoundError) {
      // redirect to a list of all posts instead
      this.transitionTo('posts');
    } else {
      // otherwise let the error bubble
      return true;
    }
  }
}

NotFoundError

ts
class NotFoundError(errors, message): void;

Defined in: packages/adapter/src/error.js:309

A NotFoundError equates to a HTTP 404 Not Found response status. It is used by an adapter to signal that a request to the external API was rejected because the resource could not be found on the API.

An example use case would be to detect if the user has entered a route for a specific model that does not exist. For example:

app/routes/post.js
js
import { NotFoundError } from '@ember-data/adapter/error';

export default class PostRoute extends Route {
  @service store;
  model(params) {
    return this.store.findRecord('post', params.post_id);
  }
  @action
  error(error, transition) {
    if (error instanceof NotFoundError) {
      // redirect to a list of all posts instead
      this.transitionTo('posts');
    } else {
      // otherwise let the error bubble
      return true;
    }
  }
}

NotFoundError

Parameters

errors

any

message

any

Returns

void

Properties

extend()

ts
static extend: (__namedParameters) => {
(errors, message): void;
  extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: ...; };
  prototype: any;
};

Defined in: packages/adapter/src/error.js:112

Parameters

__namedParameters

Returns

ts
(errors, message): void;
Parameters
errors

any

message

any

Returns

void

extend
ts
extend: ({ message: defaultMessage }?: {}) => { (errors: any, message: any): void; prototype: any; extend: ...; };
prototype
ts
prototype: any;

Released under the MIT License.