AuthInternalErrors.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. /** @var FIRAuthPublicErrorCodeFlag
  16. @brief Bitmask value indicating the error represents a public error code when this bit is
  17. zeroed. Error codes which don't contain this flag will be wrapped in an @c NSError whose
  18. code is @c FIRAuthErrorCodeInternalError.
  19. */
  20. let FIRAuthPublicErrorCodeFlag: Int = 1 << 20
  21. /** @var FIRAuthInternalErrorCode
  22. @brief Error codes used internally by Firebase Auth.
  23. @remarks All errors are generated using an internal error code. These errors are automatically
  24. converted to the appropriate public version of the @c NSError by the methods in
  25. @c FIRAuthErrorUtils
  26. */
  27. enum SharedErrorCode {
  28. case `public`(AuthErrorCode)
  29. case `internal`(AuthInternalErrorCode)
  30. }
  31. enum AuthInternalErrorCode: Int {
  32. case networkError = 17020
  33. /** @var FIRAuthInternalErrorCodeRPCRequestEncodingError
  34. @brief Indicates an error encoding the RPC request.
  35. @remarks This is typically due to some sort of unexpected input value.
  36. See the @c NSUnderlyingError value in the @c NSError.userInfo dictionary for details.
  37. */
  38. case RPCRequestEncodingError = 1
  39. /** @var FIRAuthInternalErrorCodeJSONSerializationError
  40. @brief Indicates an error serializing an RPC request.
  41. @remarks This is typically due to some sort of unexpected input value.
  42. If an @c NSJSONSerialization.isValidJSONObject: check fails, the error will contain no
  43. @c NSUnderlyingError key in the @c NSError.userInfo dictionary. If an error was
  44. encountered calling @c NSJSONSerialization.dataWithJSONObject:options:error:, the
  45. resulting error will be associated with the @c NSUnderlyingError key in the
  46. @c NSError.userInfo dictionary.
  47. */
  48. case JSONSerializationError = 2
  49. /** @var FIRAuthInternalErrorCodeUnexpectedErrorResponse
  50. @brief Indicates an HTTP error occurred and the data returned either couldn't be deserialized
  51. or couldn't be decoded.
  52. @remarks See the @c NSUnderlyingError value in the @c NSError.userInfo dictionary for details
  53. about the HTTP error which occurred.
  54. If the response could be deserialized as JSON then the @c NSError.userInfo dictionary will
  55. contain a value for the key @c FIRAuthErrorUserInfoDeserializedResponseKey which is the
  56. deserialized response value.
  57. If the response could not be deserialized as JSON then the @c NSError.userInfo dictionary
  58. will contain values for the @c NSUnderlyingErrorKey and @c FIRAuthErrorUserInfoDataKey
  59. keys.
  60. */
  61. case unexpectedErrorResponse = 3
  62. /** @var FIRAuthInternalErrorCodeUnexpectedResponse
  63. @brief Indicates the HTTP response indicated the request was a successes, but the response
  64. contains something other than a JSON-encoded dictionary, or the data type of the response
  65. indicated it is different from the type of response we expected.
  66. @remarks See the @c NSUnderlyingError value in the @c NSError.userInfo dictionary.
  67. If this key is present in the dictionary, it may contain an error from
  68. @c NSJSONSerialization error (indicating the response received was of the wrong data
  69. type).
  70. See the @c FIRAuthErrorUserInfoDeserializedResponseKey value in the @c NSError.userInfo
  71. dictionary. If the response could be deserialized, it's deserialized representation will
  72. be associated with this key. If the @c NSUnderlyingError value in the @c NSError.userInfo
  73. dictionary is @c nil, this indicates the JSON didn't represent a dictionary.
  74. */
  75. case unexpectedResponse = 4
  76. /** @var FIRAuthInternalErrorCodeRPCResponseDecodingError
  77. @brief Indicates an error decoding the RPC response.
  78. This is typically due to some sort of unexpected response value from the server.
  79. @remarks See the @c NSUnderlyingError value in the @c NSError.userInfo dictionary for details.
  80. See the @c FIRErrorUserInfoDecodedResponseKey value in the @c NSError.userInfo dictionary.
  81. The deserialized representation of the response will be associated with this key.
  82. */
  83. case RPCResponseDecodingError = 5
  84. }