/**
 * Global Error helper functions
 *
 */
export const ERROR_HARMLESS = 100;
export const ERROR_FATAL = 500;
export function ErrorHandler(error) {
  let {
    message
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
    message: null
  };
  let code = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ERROR_HARMLESS;

  if (typeof error === 'object') {
    message = error.message;
  }

  this.err = new Error("".concat(error, "\n\n").concat(message));

  if (code === ERROR_FATAL) {
    throw this.err;
  } else {
    console.log(this.err);
  }
}