Skip to content

Commit 06c8e2a

Browse files
committed
Auto merge of #2402 - Turbo87:crate-error, r=locks
crate: Fix error handling in `model()` hook If an error was thrown without an `errors` property the error handler would crash, and if the error had such a property but without the "Not Found" detail the error would still not be shown because it wasn't rethrown. r? @locks
2 parents fa5878b + 0951a52 commit 06c8e2a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/routes/crate.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import { inject as service } from '@ember/service';
44
export default Route.extend({
55
flashMessages: service(),
66

7-
model(params) {
8-
return this.store.find('crate', params.crate_id).catch(e => {
9-
if (e.errors.some(e => e.detail === 'Not Found')) {
7+
async model(params) {
8+
try {
9+
return await this.store.find('crate', params.crate_id);
10+
} catch (e) {
11+
if (e.errors?.some(e => e.detail === 'Not Found')) {
1012
this.flashMessages.show(`Crate '${params.crate_id}' does not exist`);
11-
return;
13+
} else {
14+
throw e;
1215
}
13-
});
16+
}
1417
},
1518

1619
afterModel(model) {

0 commit comments

Comments
 (0)