Exception.js 552 B

1234567891011121314151617181920212223
  1. import { CustomError } from 'ts-custom-error';
  2. /**
  3. * Custom Error class of type Exception.
  4. */
  5. export default class Exception extends CustomError {
  6. /**
  7. * Allows Exception to be constructed directly
  8. * with some message and prototype definition.
  9. */
  10. constructor(message = undefined) {
  11. super(message);
  12. this.message = message;
  13. }
  14. getKind() {
  15. const ex = this.constructor;
  16. return ex.kind;
  17. }
  18. }
  19. /**
  20. * It's typed as string so it can be extended and overriden.
  21. */
  22. Exception.kind = 'Exception';