Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Add error substate #24

Merged
merged 1 commit into from
Jan 23, 2018
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
8 changes: 4 additions & 4 deletions app/routes/version/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ export default Route.extend({
return this.transitionTo('version.show', path.replace(/\/index$/, ''))
}

let versionModel = this.modelFor('version');
const { version } = this.modelFor('version');

let contentPromise = this.store.queryRecord('content', {
path,
version: versionModel.version,
version
})
.catch((e) => {
if (['404', '403'].includes(get(e, 'errors.0.status'))) {
return this.store.queryRecord('content', {
path: `${path}/index`,
version: versionModel.version,
version
});
}
throw e;
});

return hash({
content: contentPromise,
pages: get(this, 'store').query('page', { version: get(versionModel, 'version') })
pages: get(this, 'store').query('page', { version })
})
},
});
4 changes: 4 additions & 0 deletions app/styles/_error.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.whoops {
margin: 3em auto 0 auto;
width: 54em;
}
2 changes: 2 additions & 0 deletions app/styles/app.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import 'main-header';
@import 'main-footer';

@import 'error';

@font-face {
font-family: 'fontello';
src: url("../fonts/fontello.eot?60624967");
Expand Down
11 changes: 11 additions & 0 deletions app/templates/error.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{#if (eq model.errors.0.status '404')}}
<h1 class="whoops">Ack! 404 friend, you're in the wrong place</h1>

<p>
This page wasn't found. If you were looking for documentation, please try
the <a href="http://guides.emberjs.com">Guides</a> section of the site. If you expected
something else to be here, please <a href="https://github.com/emberjs/website/issues">file a ticket</a>.
</p>
{{else}}
<p>An error occurred! Please try again.</p>
{{/if}}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"ember-prism": "^0.2.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.18.0",
"ember-truth-helpers": "^2.0.0",
"ember-welcome-page": "^3.0.0",
"eslint-plugin-ember": "^5.0.0",
"loader.js": "^4.2.3",
Expand Down