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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/ergochat/ergo/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. errAccountSuspended = errors.New(`Account has been suspended`)
  28. errAccountVerificationFailed = errors.New("Account verification failed")
  29. errAccountVerificationInvalidCode = errors.New("Invalid account verification code")
  30. errAccountUpdateFailed = errors.New(`Error while updating your account information`)
  31. errAccountMustHoldNick = errors.New(`You must hold that nickname in order to register it`)
  32. errAuthzidAuthcidMismatch = errors.New(`authcid and authzid must be the same`)
  33. errCallbackFailed = errors.New("Account verification could not be sent")
  34. errCertfpAlreadyExists = errors.New(`An account already exists for your certificate fingerprint`)
  35. errChannelNotOwnedByAccount = errors.New("Channel not owned by the specified account")
  36. errChannelTransferNotOffered = errors.New(`You weren't offered ownership of that channel`)
  37. errChannelAlreadyRegistered = errors.New("Channel is already registered")
  38. errChannelNotRegistered = errors.New("Channel is not registered")
  39. errChannelNameInUse = errors.New(`Channel name in use`)
  40. errInvalidChannelName = errors.New(`Invalid channel name`)
  41. errMonitorLimitExceeded = errors.New("Monitor limit exceeded")
  42. errNickMissing = errors.New("nick missing")
  43. errNicknameInvalid = errors.New("invalid nickname")
  44. errNicknameInUse = errors.New("nickname in use")
  45. errInsecureReattach = errors.New("insecure reattach")
  46. errNicknameReserved = errors.New("nickname is reserved")
  47. errNickAccountMismatch = errors.New(`Your nickname must match your account name; try logging out and logging back in with SASL`)
  48. errNoExistingBan = errors.New("Ban does not exist")
  49. errNoSuchChannel = errors.New(`No such channel`)
  50. errChannelPurged = errors.New(`This channel was purged by the server operators and cannot be used`)
  51. errConfusableIdentifier = errors.New("This identifier is confusable with one already in use")
  52. errInsufficientPrivs = errors.New("Insufficient privileges")
  53. errInvalidUsername = errors.New("Invalid username")
  54. errFeatureDisabled = errors.New(`That feature is disabled`)
  55. errBanned = errors.New("IP or nickmask banned")
  56. errInvalidParams = utils.ErrInvalidParams
  57. errNoVhost = errors.New(`You do not have an approved vhost`)
  58. errLimitExceeded = errors.New("Limit exceeded")
  59. errNoop = errors.New("Action was a no-op")
  60. errCASFailed = errors.New("Compare-and-swap update of database value failed")
  61. errEmptyCredentials = errors.New("No more credentials are approved")
  62. errCredsExternallyManaged = errors.New("Credentials are externally managed and cannot be changed here")
  63. errInvalidMultilineBatch = errors.New("Invalid multiline batch")
  64. errTimedOut = errors.New("Operation timed out")
  65. errInvalidUtf8 = errors.New("Message rejected for invalid utf8")
  66. errClientDestroyed = errors.New("Client was already destroyed")
  67. errTooManyChannels = errors.New("You have joined too many channels")
  68. errWrongChannelKey = errors.New("Cannot join password-protected channel without the password")
  69. errInviteOnly = errors.New("Cannot join invite-only channel without an invite")
  70. errRegisteredOnly = errors.New("Cannot join registered-only channel without an account")
  71. errValidEmailRequired = errors.New("A valid email address is required for account registration")
  72. errInvalidAccountRename = errors.New("Account renames can only change the casefolding of the account name")
  73. )
  74. // String Errors
  75. var (
  76. errCouldNotStabilize = errors.New("Could not stabilize string while casefolding")
  77. errStringIsEmpty = errors.New("String is empty")
  78. errInvalidCharacter = errors.New("Invalid character")
  79. )
  80. type CertKeyError struct {
  81. Err error
  82. }
  83. func (ck *CertKeyError) Error() string {
  84. return fmt.Sprintf("Invalid TLS cert/key pair: %v", ck.Err)
  85. }
  86. type ThrottleError struct {
  87. time.Duration
  88. }
  89. func (te *ThrottleError) Error() string {
  90. return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration)
  91. }