This Util is all about making clearer and easy to define error messages from server side errors. Most notably, it automatically takes an error and formats it in such a way to make the message make sense, but it also has a download link to download the whole stack trace of the error if the error cannot properly fit onto a one line error message. This should be used anytime that there is an error from a serverside because otherwise, the link will likely not be setup properly. As a suggestion modals should use the createErrorMessage and non-modals should probably use handleAjaxError. Each of the "methods" in this documentation are actually different functionss you are able to import, but beware that the only ones you should probably be using are the non-private functions unless you have a very good reason for using a private function.

Import syntax:

import {functionName} from '@bennerinformatics/ember-fw/utils/error';

//where functionName is the name of the function, so for example, the "createErrorMessage" function would have the following syntax
import {createErrorMessage} from '@bennerinformatics/ember-fw/utils/error';
Show:
createErrorMessage
(
  • error
)
String

Creates a full error message based on the given error payload. This function should be used in contexts when the outlet is not fixed.

Usage Example:

promise.catch((error) => {
    this.get('notifications').showError(createErrorMessage(error), 'modal-top', true);
  });
  

Parameters:

  • error Error

    Error object

Returns:

String:

Notification error message

getTitle
(
  • error
)
String
private

Gets the title to display for an error object using both the status and the error message. This is primarily an internal function used by both createErrorMessage and handleAjaxError.

Parameters:

  • error Error

    Error object

Returns:

String:

String title

handleAjaxError
(
  • error
)

All in one logic to handle an ajax error message. This also will handle the error and place it in the fixed outlet only, so if the error message is to go to the fixed outlet, use this, otherwise use createErrorMessage. Requires notifications to be injected into the calling controller/component and being bound to that object.

Usage Example:

promise.catch(handleAjaxError.bind(this));
  

Parameters:

  • error Error

    Error object