You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.5 KiB

  1. class BaseError extends Error {
  2. constructor (message) {
  3. super(message)
  4. this.name = this.constructor.name
  5. Error.captureStackTrace(this, this.constructor)
  6. }
  7. }
  8. class AuthGenericError extends BaseError { constructor (message = 'An unexpected error occured during login.') { super(message) } }
  9. class AuthLoginFailed extends BaseError { constructor (message = 'Invalid email / username or password.') { super(message) } }
  10. class AuthProviderInvalid extends BaseError { constructor (message = 'Invalid authentication provider.') { super(message) } }
  11. class AuthTFAFailed extends BaseError { constructor (message = 'Incorrect TFA Security Code.') { super(message) } }
  12. class AuthTFAInvalid extends BaseError { constructor (message = 'Invalid TFA Security Code or Login Token.') { super(message) } }
  13. class BruteInstanceIsInvalid extends BaseError { constructor (message = 'Invalid Brute Force Instance.') { super(message) } }
  14. class BruteTooManyAttempts extends BaseError { constructor (message = 'Too many attempts! Try again later.') { super(message) } }
  15. class LocaleInvalidNamespace extends BaseError { constructor (message = 'Invalid locale or namespace.') { super(message) } }
  16. class UserCreationFailed extends BaseError { constructor (message = 'An unexpected error occured during user creation.') { super(message) } }
  17. module.exports = {
  18. BaseError,
  19. AuthGenericError,
  20. AuthLoginFailed,
  21. AuthProviderInvalid,
  22. AuthTFAFailed,
  23. AuthTFAInvalid,
  24. BruteInstanceIsInvalid,
  25. BruteTooManyAttempts,
  26. LocaleInvalidNamespace,
  27. UserCreationFailed
  28. }