base.go

    1. // Common: basic errors.
    2. // Code must start with 1xxxxx.
    3. const (
    4. // ErrSuccess - 200: OK.
    5. ErrSuccess int = iota + 100001
    6. // ErrUnknown - 500: Internal server error.
    7. ErrUnknown
    8. // ErrBind - 400: Error occurred while binding the request body to the struct.
    9. ErrBind
    10. // ErrValidation - 400: Validation failed.
    11. ErrValidation
    12. // ErrTokenInvalid - 401: Token invalid.
    13. ErrTokenInvalid
    14. // ErrPageNotFound - 404: Page not found.
    15. ErrPageNotFound
    16. )
    17. // common: database errors.
    18. const (
    19. // ErrDatabase - 500: Database error.
    20. ErrDatabase int = iota + 100101
    21. )
    22. // common: authorization and authentication errors.
    23. const (
    24. // ErrEncrypt - 401: Error occurred while encrypting the user password.
    25. ErrEncrypt int = iota + 100201
    26. // ErrSignatureInvalid - 401: Signature is invalid.
    27. ErrSignatureInvalid
    28. // ErrExpired - 401: Token expired.
    29. ErrExpired
    30. // ErrInvalidAuthHeader - 401: Invalid authorization header.
    31. ErrInvalidAuthHeader
    32. // ErrMissingHeader - 401: The `Authorization` header was empty.
    33. ErrMissingHeader
    34. // ErrPasswordIncorrect - 401: Password was incorrect.
    35. ErrPasswordIncorrect
    36. // PermissionDenied - 403: Permission denied.
    37. ErrPermissionDenied
    38. )
    39. // common: encode/decode errors.
    40. const (
    41. // ErrEncodingFailed - 500: Encoding failed due to an error with the data.
    42. ErrEncodingFailed int = iota + 100301
    43. // ErrDecodingFailed - 500: Decoding failed due to an error with the data.
    44. ErrDecodingFailed
    45. // ErrInvalidJSON - 500: Data is not valid JSON.
    46. ErrInvalidJSON
    47. // ErrEncodingJSON - 500: JSON data could not be encoded.
    48. ErrEncodingJSON
    49. // ErrDecodingJSON - 500: JSON data could not be decoded.
    50. ErrDecodingJSON
    51. // ErrInvalidYaml - 500: Data is not valid Yaml.
    52. ErrInvalidYaml
    53. // ErrEncodingYaml - 500: Yaml data could not be encoded.
    54. ErrEncodingYaml
    55. // ErrDecodingYaml - 500: Yaml data could not be decoded.
    56. ErrDecodingYaml
    57. )

    error源码
    error源码