error.go 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package fiber
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "github.com/gofiber/schema"
  6. )
  7. // Wrap and return this for unreachable code if panicking is undesirable (i.e., in a handler).
  8. // Unexported because users will hopefully never need to see it.
  9. var errUnreachable = errors.New("fiber: unreachable code, please create an issue at github.com/gofiber/fiber")
  10. // General errors
  11. var (
  12. ErrGracefulTimeout = errors.New("shutdown: graceful timeout has been reached, exiting")
  13. // ErrNotRunning indicates that a Shutdown method was called when the server was not running.
  14. ErrNotRunning = errors.New("shutdown: server is not running")
  15. // ErrHandlerExited is returned by App.Test if a handler panics or calls runtime.Goexit().
  16. ErrHandlerExited = errors.New("runtime.Goexit() called in handler or server panic")
  17. // ErrNoViewEngineConfigured indicates that a helper requiring a view engine was invoked without one configured.
  18. ErrNoViewEngineConfigured = errors.New("fiber: no view engine configured")
  19. // ErrAutoCertWithCertFile indicates AutoCertManager cannot be used with CertFile/CertKeyFile.
  20. ErrAutoCertWithCertFile = errors.New("tls: AutoCertManager cannot be combined with CertFile/CertKeyFile")
  21. )
  22. // Fiber redirection errors
  23. var (
  24. ErrRedirectBackNoFallback = NewError(StatusInternalServerError, "Referer not found, you have to enter fallback URL for redirection.")
  25. )
  26. // Range errors
  27. var (
  28. ErrRangeMalformed = errors.New("range: malformed range header string")
  29. ErrRangeTooLarge = NewError(StatusRequestedRangeNotSatisfiable, "range: too many ranges")
  30. ErrRangeUnsatisfiable = errors.New("range: unsatisfiable range")
  31. )
  32. // Binder errors
  33. var ErrCustomBinderNotFound = errors.New("binder: custom binder not found, please be sure to enter the right name")
  34. // Format errors
  35. var (
  36. // ErrNoHandlers is returned when c.Format is called with no arguments.
  37. ErrNoHandlers = errors.New("format: at least one handler is required, but none were set")
  38. )
  39. // gofiber/schema errors
  40. type (
  41. // ConversionError Conversion error exposes the internal schema.ConversionError for public use.
  42. ConversionError = schema.ConversionError
  43. // UnknownKeyError error exposes the internal schema.UnknownKeyError for public use.
  44. UnknownKeyError = schema.UnknownKeyError
  45. // EmptyFieldError error exposes the internal schema.EmptyFieldError for public use.
  46. EmptyFieldError = schema.EmptyFieldError
  47. // MultiError error exposes the internal schema.MultiError for public use.
  48. MultiError = schema.MultiError
  49. )
  50. // encoding/json errors
  51. type (
  52. // InvalidUnmarshalError describes an invalid argument passed to Unmarshal.
  53. // (The argument to Unmarshal must be a non-nil pointer.)
  54. InvalidUnmarshalError = json.InvalidUnmarshalError
  55. // MarshalerError represents an error from calling a MarshalJSON or MarshalText method.
  56. MarshalerError = json.MarshalerError
  57. // SyntaxError is a description of a JSON syntax error.
  58. SyntaxError = json.SyntaxError
  59. // UnmarshalTypeError describes a JSON value that was
  60. // not appropriate for a value of a specific Go type.
  61. UnmarshalTypeError = json.UnmarshalTypeError
  62. // UnsupportedTypeError is returned by Marshal when attempting
  63. // to encode an unsupported value type.
  64. UnsupportedTypeError = json.UnsupportedTypeError
  65. // UnsupportedValueError exposes json.UnsupportedValueError to describe unsupported values encountered during encoding.
  66. UnsupportedValueError = json.UnsupportedValueError
  67. )