Home Intro Source Mebo GitHub

src/MeboError.js

  1. const Settings = require('./Settings');
  2.  
  3. /**
  4. * Base exception class used by mebo exceptions.
  5. */
  6. class MeboError extends Error{
  7.  
  8. constructor(message){
  9. super(message);
  10.  
  11. /**
  12. * Status code used by the {@link Handler} when this error is raised from inside of a top
  13. * level action (an action that has not been created from another action).
  14. *
  15. * Value driven by:
  16. * `Settings.get('error/status')`
  17. * (default: `500`)
  18. *
  19. * @type {number}
  20. */
  21. this.status = Settings.get('error/status');
  22.  
  23. /**
  24. * Boolean telling if this error is not allowed as output ({@link Handler.output})
  25. * when it has been raised from a nested action (an action created from another
  26. * action ({@link Action.createAction})). When output is disabled the error
  27. * will not be handled by the {@link Writer}, therefore the error will be
  28. * emitted by the signal {@link Handler.onErrorDuringOutput}.
  29. *
  30. * Value driven by:
  31. * `Settings.get('error/disableOutputInNested')`
  32. * (default: `false`)
  33. *
  34. * @type {boolean}
  35. */
  36. this.disableOutputInNested = Settings.get('error/disableOutputInNested');
  37. }
  38. }
  39.  
  40. // default settings
  41. Settings.set('error/status', 500);
  42. Settings.set('error/disableOutputInNested', false);
  43.  
  44. module.exports = MeboError;