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.

errors.go 5.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (c) 2012-2014 Jeremy Latt
  2. // Copyright (c) 2014-2015 Edmund Huber
  3. // Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
  4. // released under the MIT license
  5. package irc
  6. import (
  7. "errors"
  8. "fmt"
  9. "time"
  10. "github.com/oragono/oragono/irc/utils"
  11. )
  12. // Runtime Errors
  13. var (
  14. errAccountAlreadyRegistered = errors.New(`Account already exists`)
  15. errAccountAlreadyUnregistered = errors.New(`That account name was registered previously and can't be reused`)
  16. errAccountAlreadyVerified = errors.New(`Account is already verified`)
  17. errAccountCantDropPrimaryNick = errors.New("Can't unreserve primary nickname")
  18. errAccountCreation = errors.New("Account could not be created")
  19. errAccountDoesNotExist = errors.New("Account does not exist")
  20. errAccountInvalidCredentials = errors.New("Invalid account credentials")
  21. errAccountBadPassphrase = errors.New(`Passphrase contains forbidden characters or is otherwise invalid`)
  22. errAccountNickReservationFailed = errors.New("Could not (un)reserve nick")
  23. errAccountNotLoggedIn = errors.New("You're not logged into an account")
  24. errAccountAlreadyLoggedIn = errors.New("You're already logged into an account")
  25. errAccountTooManyNicks = errors.New("Account has too many reserved nicks")
  26. errAccountUnverified = errors.New(`Account is not yet verified`)
  27. errAccountVerificationFailed = errors.New("Account verification failed")
  28. errAccountVerificationInvalidCode = errors.New("Invalid account verification code")
  29. errAccountUpdateFailed = errors.New(`Error while updating your account information`)
  30. errAccountMustHoldNick = errors.New(`You must hold that nickname in order to register it`)
  31. errAuthzidAuthcidMismatch = errors.New(`authcid and authzid must be the same`)
  32. errCallbackFailed = errors.New("Account verification could not be sent")
  33. errCertfpAlreadyExists = errors.New(`An account already exists for your certificate fingerprint`)
  34. errChannelNotOwnedByAccount = errors.New("Channel not owned by the specified account")
  35. errChannelTransferNotOffered = errors.New(`You weren't offered ownership of that channel`)
  36. errChannelAlreadyRegistered = errors.New("Channel is already registered")
  37. errChannelNotRegistered = errors.New("Channel is not registered")
  38. errChannelNameInUse = errors.New(`Channel name in use`)
  39. errInvalidChannelName = errors.New(`Invalid channel name`)
  40. errMonitorLimitExceeded = errors.New("Monitor limit exceeded")
  41. errNickMissing = errors.New("nick missing")
  42. errNicknameInvalid = errors.New("invalid nickname")
  43. errNicknameInUse = errors.New("nickname in use")
  44. errInsecureReattach = errors.New("insecure reattach")
  45. errNicknameReserved = errors.New("nickname is reserved")
  46. errNickAccountMismatch = errors.New(`Your nickname must match your account name; try logging out and logging back in with SASL`)
  47. errNoExistingBan = errors.New("Ban does not exist")
  48. errNoSuchChannel = errors.New(`No such channel`)
  49. errChannelPurged = errors.New(`This channel was purged by the server operators and cannot be used`)
  50. errConfusableIdentifier = errors.New("This identifier is confusable with one already in use")
  51. errInsufficientPrivs = errors.New("Insufficient privileges")
  52. errInvalidUsername = errors.New("Invalid username")
  53. errFeatureDisabled = errors.New(`That feature is disabled`)
  54. errBanned = errors.New("IP or nickmask banned")
  55. errInvalidParams = utils.ErrInvalidParams
  56. errNoVhost = errors.New(`You do not have an approved vhost`)
  57. errLimitExceeded = errors.New("Limit exceeded")
  58. errNoop = errors.New("Action was a no-op")
  59. errCASFailed = errors.New("Compare-and-swap update of database value failed")
  60. errEmptyCredentials = errors.New("No more credentials are approved")
  61. errCredsExternallyManaged = errors.New("Credentials are externally managed and cannot be changed here")
  62. errInvalidMultilineBatch = errors.New("Invalid multiline batch")
  63. errTimedOut = errors.New("Operation timed out")
  64. errInvalidUtf8 = errors.New("Message rejected for invalid utf8")
  65. errClientDestroyed = errors.New("Client was already destroyed")
  66. errTooManyChannels = errors.New("You have joined too many channels")
  67. errWrongChannelKey = errors.New("Cannot join password-protected channel without the password")
  68. errInviteOnly = errors.New("Cannot join invite-only channel without an invite")
  69. errRegisteredOnly = errors.New("Cannot join registered-only channel without an account")
  70. errValidEmailRequired = errors.New("A valid email address is required for account registration")
  71. )
  72. // String Errors
  73. var (
  74. errCouldNotStabilize = errors.New("Could not stabilize string while casefolding")
  75. errStringIsEmpty = errors.New("String is empty")
  76. errInvalidCharacter = errors.New("Invalid character")
  77. )
  78. type CertKeyError struct {
  79. Err error
  80. }
  81. func (ck *CertKeyError) Error() string {
  82. return fmt.Sprintf("Invalid TLS cert/key pair: %v", ck.Err)
  83. }
  84. type ThrottleError struct {
  85. time.Duration
  86. }
  87. func (te *ThrottleError) Error() string {
  88. return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration)
  89. }