refactor: Update comments and tests for error message

This commit is contained in:
Susmitha Girumala committed 2020-09-16 15:25:35 -04:00
1 parent aa9eb4f8d4
commit cfd1ac81fb
5 files changed
+62 -42

No files matched your search

+3 -1
View File
@@ -1,4 +1,6 @@
<Rose::Message @title={{t this.title}} @subtitle={{t this.subtitle}} @icon={{this.icon}} as |message|>
<message.description>{{t this.description}}</message.description>
<message.link @route={{this.helpRoute}}>{{t "actions.help"}}</message.link>
{{#if this.helpRoute}}
<message.link @route={{this.helpRoute}}>{{t "actions.help"}}</message.link>
{{/if}}
</Rose::Message>
+27 -24
View File
@@ -1,50 +1,50 @@
import Message from 'rose/components/rose/message';
/*
* Helpful error booleans are attached based on the error status code:
*
* - 401 - `error.isUnauthenticated`: the session isn't authenticated
* - 403 - `error.isForbidden`: the session is authenticated but does not have
* permission to perform the requested action
* - 404 - `error.isNotFound`: the requested resource could not be found
* - 500 - `error.isServer`: an internal server error occurred
*
* For an unknown error state, i.e error state not matching to the above defined list:
* - unknown - `error.isUnknown`: an error occurred, but we don't know which or
* we don't distinguish it yet
*/
* Helpful error booleans are attached based on the error status code:
*
* - 401 - `error.isUnauthenticated`: the session isn't authenticated
* - 403 - `error.isForbidden`: the session is authenticated but does not have
* permission to perform the requested action
* - 404 - `error.isNotFound`: the requested resource could not be found
* - 500 - `error.isServer`: an internal server error occurred
*
* For an unknown error state, i.e error state not matching to the above defined list:
* - unknown - `error.isUnknown`: an error occurred, but we don't know which or
* we don't distinguish it yet
*/
const status_messages = {
'401' : {
'401': {
icon: 'disabled',
title: 'errors.titles.unauthenticated-error',
subtitle: 'errors.subtitles.unauthenticated-error',
description: 'errors.descriptions.unauthenticated-error',
},
'403' : {
'403': {
icon: 'disabled',
title: 'errors.titles.forbidden-error',
subtitle: 'errors.subtitles.forbidden-error',
description: 'errors.descriptions.forbidden-error',
},
'404' : {
'404': {
icon: 'help-circle-outline',
title: 'errors.titles.notfound-error',
subtitle: 'errors.subtitles.notfound-error',
description: 'errors.descriptions.notfound-error',
},
'500' : {
'500': {
icon: 'alert-circle-outline',
title: 'errors.titles.server-error',
subtitle: 'errors.subtitles.server-error',
description: 'errors.descriptions.server-error',
},
'unknown' : {
unknown: {
icon: 'alert-circle-outline',
title: 'errors.titles.unknown-error',
subtitle: 'errors.subtitles.unknown-error',
description: 'errors.descriptions.unknown-error',
}
},
};
export default class ErrorMessageComponent extends Message {
@@ -82,23 +82,26 @@ export default class ErrorMessageComponent extends Message {
return this.statusMessage.description;
}
// Disable until help documentation can be linked in.
/**
* Returns an route string for help text in message.
* @return {string}
*/
get helpRoute() {
return 'index'
}
// get helpRoute() {
// return 'index'
// }
/**
* Returns an object with message details based on error status.
* Return message for `unkown` error when error status isn't part of
* Return message for `unknown` error when error status isn't part of
* predefined message set.
* @return {object}
*/
get statusMessage() {
let status = this.status;
if(!status_messages[status]) { status = 'unknown'; }
if (!status_messages[status]) {
status = 'unknown';
}
return status_messages[status];
}
}
}