Skip to content

Commit d2b938b

Browse files
committed
Auto merge of #4477 - Turbo87:errors, r=Turbo87
Adjust error page titles This makes them a bit more consistent and useful :)
2 parents ec6bacf + 38ca8db commit d2b938b

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

app/routes/crate.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ export default class CrateRoute extends Route {
77
@service store;
88

99
async model(params, transition) {
10+
let crateName = params.crate_id;
11+
1012
try {
11-
return await this.store.find('crate', params.crate_id);
13+
return await this.store.find('crate', crateName);
1214
} catch (error) {
1315
if (error.errors?.some(e => e.detail === 'Not Found')) {
14-
this.router.replaceWith('catch-all', { transition, error, title: 'Crate not found' });
16+
let title = `${crateName}: Crate not found`;
17+
this.router.replaceWith('catch-all', { transition, error, title });
1518
} else {
16-
this.router.replaceWith('catch-all', { transition, error, title: 'Crate failed to load', tryAgain: true });
19+
let title = `${crateName}: Failed to load crate data`;
20+
this.router.replaceWith('catch-all', { transition, error, title, tryAgain: true });
1721
}
1822
}
1923
}

app/routes/crate/version.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ export default class VersionRoute extends Route {
1616
try {
1717
versions = await crate.get('versions');
1818
} catch (error) {
19-
return this.router.replaceWith('catch-all', { transition, error, title: 'Crate failed to load', tryAgain: true });
19+
let title = `${crate.name}: Failed to load version data`;
20+
return this.router.replaceWith('catch-all', { transition, error, title, tryAgain: true });
2021
}
2122

2223
let version;
2324
let requestedVersion = params.version_num;
2425
if (requestedVersion) {
2526
version = versions.find(version => version.num === requestedVersion);
2627
if (!version) {
27-
return this.router.replaceWith('catch-all', { transition, title: 'Version not found' });
28+
let title = `${crate.name}: Version ${requestedVersion} not found`;
29+
return this.router.replaceWith('catch-all', { transition, title });
2830
}
2931
} else {
3032
let { defaultVersion } = crate;

tests/acceptance/crate-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module('Acceptance | crate page', function (hooks) {
8585
await visit('/crates/nanomsg');
8686
assert.equal(currentURL(), '/crates/nanomsg');
8787
assert.dom('[data-test-404-page]').exists();
88-
assert.dom('[data-test-title]').hasText('Crate not found');
88+
assert.dom('[data-test-title]').hasText('nanomsg: Crate not found');
8989
assert.dom('[data-test-go-back]').exists();
9090
assert.dom('[data-test-try-again]').doesNotExist();
9191
});
@@ -96,7 +96,7 @@ module('Acceptance | crate page', function (hooks) {
9696
await visit('/crates/nanomsg');
9797
assert.equal(currentURL(), '/crates/nanomsg');
9898
assert.dom('[data-test-404-page]').exists();
99-
assert.dom('[data-test-title]').hasText('Crate failed to load');
99+
assert.dom('[data-test-title]').hasText('nanomsg: Failed to load crate data');
100100
assert.dom('[data-test-go-back]').doesNotExist();
101101
assert.dom('[data-test-try-again]').exists();
102102
});
@@ -110,7 +110,7 @@ module('Acceptance | crate page', function (hooks) {
110110

111111
assert.equal(currentURL(), '/crates/nanomsg/0.7.0');
112112
assert.dom('[data-test-404-page]').exists();
113-
assert.dom('[data-test-title]').hasText('Version not found');
113+
assert.dom('[data-test-title]').hasText('nanomsg: Version 0.7.0 not found');
114114
assert.dom('[data-test-go-back]').exists();
115115
assert.dom('[data-test-try-again]').doesNotExist();
116116
});
@@ -126,7 +126,7 @@ module('Acceptance | crate page', function (hooks) {
126126
await click('[data-test-just-updated] [data-test-crate-link="0"]');
127127
assert.equal(currentURL(), '/crates/nanomsg');
128128
assert.dom('[data-test-404-page]').exists();
129-
assert.dom('[data-test-title]').hasText('Crate failed to load');
129+
assert.dom('[data-test-title]').hasText('nanomsg: Failed to load version data');
130130
assert.dom('[data-test-go-back]').doesNotExist();
131131
assert.dom('[data-test-try-again]').exists();
132132
});

tests/routes/crate/range-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module('Route | crate.range', function (hooks) {
8282
await visit('/crates/foo/range/^3');
8383
assert.equal(currentURL(), '/crates/foo/range/%5E3');
8484
assert.dom('[data-test-404-page]').exists();
85-
assert.dom('[data-test-title]').hasText('Crate not found');
85+
assert.dom('[data-test-title]').hasText('foo: Crate not found');
8686
assert.dom('[data-test-go-back]').exists();
8787
assert.dom('[data-test-try-again]').doesNotExist();
8888
});
@@ -93,7 +93,7 @@ module('Route | crate.range', function (hooks) {
9393
await visit('/crates/foo/range/^3');
9494
assert.equal(currentURL(), '/crates/foo/range/%5E3');
9595
assert.dom('[data-test-404-page]').exists();
96-
assert.dom('[data-test-title]').hasText('Crate failed to load');
96+
assert.dom('[data-test-title]').hasText('foo: Failed to load crate data');
9797
assert.dom('[data-test-go-back]').doesNotExist();
9898
assert.dom('[data-test-try-again]').exists();
9999
});

tests/routes/crate/version/model-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module('Route | crate.version | model() hook', function (hooks) {
3131
await visit('/crates/foo/2.0.0');
3232
assert.equal(currentURL(), `/crates/foo/2.0.0`);
3333
assert.dom('[data-test-404-page]').exists();
34-
assert.dom('[data-test-title]').hasText('Version not found');
34+
assert.dom('[data-test-title]').hasText('foo: Version 2.0.0 not found');
3535
assert.dom('[data-test-go-back]').exists();
3636
assert.dom('[data-test-try-again]').doesNotExist();
3737
});

0 commit comments

Comments
 (0)