1
0

errors.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @module lib/errors
  3. * Contains custom error classes
  4. */
  5. /** Base class for all UserUtils errors - adds a `date` prop set to the error throw time */
  6. export class UUError extends Error {
  7. public readonly date: Date;
  8. constructor(message: string, options?: ErrorOptions) {
  9. super(message, options);
  10. this.date = new Date();
  11. }
  12. }
  13. /** Error while validating checksum */
  14. export class ChecksumMismatchError extends UUError {
  15. constructor(message: string, options?: ErrorOptions) {
  16. super(message, options);
  17. this.name = "ChecksumMismatchError";
  18. }
  19. }
  20. /** Error while migrating data */
  21. export class MigrationError extends UUError {
  22. constructor(message: string, options?: ErrorOptions) {
  23. super(message, options);
  24. this.name = "MigrationError";
  25. }
  26. }
  27. /** Error due to the platform, like using a feature that's not supported by the browser */
  28. export class PlatformError extends UUError {
  29. constructor(message: string, options?: ErrorOptions) {
  30. super(message, options);
  31. this.name = "PlatformError";
  32. }
  33. }