Skip to content

Use instanceof NotFoundError for 404 checks #7915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/routes/crate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NotFoundError } from '@ember-data/adapter/error';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

Expand All @@ -12,7 +13,7 @@ export default class CrateRoute extends Route {
try {
return await this.store.findRecord('crate', crateName);
} catch (error) {
if (error.errors?.some(e => e.detail === 'Not Found')) {
if (error instanceof NotFoundError) {
let title = `${crateName}: Crate not found`;
this.router.replaceWith('catch-all', { transition, error, title });
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/routes/team.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NotFoundError } from '@ember-data/adapter/error';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

Expand All @@ -23,7 +24,7 @@ export default class TeamRoute extends Route {

return { crates, team };
} catch (error) {
if (error.errors?.some(e => e.detail === 'Not Found')) {
if (error instanceof NotFoundError) {
this.notifications.error(`Team '${params.team_id}' does not exist`);
return this.router.replaceWith('index');
}
Expand Down
3 changes: 2 additions & 1 deletion app/routes/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NotFoundError } from '@ember-data/adapter/error';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

Expand All @@ -22,7 +23,7 @@ export default class UserRoute extends Route {

return { crates, user };
} catch (error) {
if (error.errors?.some(e => e.detail === 'Not Found')) {
if (error instanceof NotFoundError) {
this.notifications.error(`User '${params.user_id}' does not exist`);
return this.router.replaceWith('index');
}
Expand Down