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 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. errVhostsForbidden = errors.New(`An administrator has denied you the ability to use vhosts`)
  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. )
  72. // Socket Errors
  73. var (
  74. errNoPeerCerts = errors.New("Client did not provide a certificate")
  75. errNotTLS = errors.New("Not a TLS connection")
  76. errReadQ = errors.New("ReadQ Exceeded")
  77. )
  78. // String Errors
  79. var (
  80. errCouldNotStabilize = errors.New("Could not stabilize string while casefolding")
  81. errStringIsEmpty = errors.New("String is empty")
  82. errInvalidCharacter = errors.New("Invalid character")
  83. )
  84. type CertKeyError struct {
  85. Err error
  86. }
  87. func (ck *CertKeyError) Error() string {
  88. return fmt.Sprintf("Invalid TLS cert/key pair: %v", ck.Err)
  89. }
  90. type ThrottleError struct {
  91. time.Duration
  92. }
  93. func (te *ThrottleError) Error() string {
  94. return fmt.Sprintf(`Please wait at least %v and try again`, te.Duration)
  95. }
  96. // Config Errors
  97. var (
  98. ErrDatastorePathMissing = errors.New("Datastore path missing")
  99. ErrLimitsAreInsane = errors.New("Limits aren't setup properly, check them and make them sane")
  100. ErrLineLengthsTooSmall = errors.New("Line lengths must be 512 or greater (check the linelen section under server->limits)")
  101. ErrLoggerExcludeEmpty = errors.New("Encountered logging type '-' with no type to exclude")
  102. ErrLoggerFilenameMissing = errors.New("Logging configuration specifies 'file' method but 'filename' is empty")
  103. ErrLoggerHasNoTypes = errors.New("Logger has no types to log")
  104. ErrNetworkNameMissing = errors.New("Network name missing")
  105. ErrNoFingerprintOrPassword = errors.New("Fingerprint or password needs to be specified")
  106. ErrNoListenersDefined = errors.New("Server listening addresses missing")
  107. ErrOperClassDependencies = errors.New("OperClasses contains a looping dependency, or a class extends from a class that doesn't exist")
  108. ErrServerNameMissing = errors.New("Server name missing")
  109. ErrServerNameNotHostname = errors.New("Server name must match the format of a hostname")
  110. )