AuthInternalErrors.swift 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /// Bitmask value indicating the error represents a public error code when this bit is
  16. /// zeroed. Error codes which don't contain this flag will be wrapped in an `NSError` whose
  17. /// code is `AuthErrorCodeInternalError`.
  18. let FIRAuthPublicErrorCodeFlag: Int = 1 << 20
  19. enum SharedErrorCode {
  20. case `public`(AuthErrorCode)
  21. case `internal`(AuthInternalErrorCode)
  22. }
  23. /// Error codes used internally by Firebase Auth.
  24. ///
  25. /// All errors are generated using an internal error code. These errors are automatically
  26. /// converted to the appropriate public version of the `NSError` by the methods in AuthErrorUtils.
  27. enum AuthInternalErrorCode: Int {
  28. /// Indicates a network error occurred (such as a timeout, interrupted connection, or
  29. /// unreachable host.)
  30. ///
  31. /// These types of errors are often recoverable with a retry.
  32. ///
  33. /// See the `NSUnderlyingError` value in the `NSError.userInfo` dictionary for details about
  34. /// the network error which occurred.
  35. case networkError = 17020
  36. /// Indicates an error encoding the RPC request.
  37. ///
  38. /// This is typically due to some sort of unexpected input value.
  39. ///
  40. /// See the `NSUnderlyingError` value in the `NSError.userInfo` dictionary for details.
  41. case RPCRequestEncodingError = 1
  42. /// Indicates an error serializing an RPC request.
  43. ///
  44. /// This is typically due to some sort of unexpected input value.
  45. ///
  46. /// If an `JSONSerialization.isValidJSONObject` check fails, the error will contain no
  47. /// `NSUnderlyingError` key in the `NSError.userInfo` dictionary. If an error was
  48. /// encountered calling `NSJSONSerialization.dataWithJSONObject`, the
  49. /// resulting error will be associated with the `NSUnderlyingError` key in the
  50. /// `NSError.userInfo` dictionary.
  51. case JSONSerializationError = 2
  52. /// Indicates an HTTP error occurred and the data returned either couldn't be deserialized
  53. /// or couldn't be decoded.
  54. ///
  55. /// See the `NSUnderlyingError` value in the `NSError.userInfo` dictionary for details
  56. /// about the HTTP error which occurred.
  57. ///
  58. /// If the response could be deserialized as JSON then the `NSError.userInfo` dictionary will
  59. /// contain a value for the key `AuthErrorUserInfoDeserializedResponseKey` which is the
  60. /// deserialized response value.
  61. ///
  62. /// If the response could not be deserialized as JSON then the `NSError.userInfo` dictionary
  63. /// will contain values for the `NSUnderlyingErrorKey` and `AuthErrorUserInfoDataKey` keys.
  64. case unexpectedErrorResponse = 3
  65. /// Indicates the HTTP response indicated the request was a successes, but the response
  66. /// contains something other than a JSON-encoded dictionary, or the data type of the response
  67. /// indicated it is different from the type of response we expected.
  68. ///
  69. /// See the `NSUnderlyingError` value in the `NSError.userInfo` dictionary.
  70. /// If this key is present in the dictionary, it may contain an error from
  71. /// `NSJSONSerialization` error (indicating the response received was of the wrong data type).
  72. ///
  73. /// See the `AuthErrorUserInfoDeserializedResponseKey` value in the `NSError.userInfo`
  74. /// dictionary. If the response could be deserialized, it's deserialized representation will
  75. /// be associated with this key. If the @c NSUnderlyingError value in the @c NSError.userInfo
  76. /// dictionary is @c nil, this indicates the JSON didn't represent a dictionary.
  77. case unexpectedResponse = 4
  78. /// Indicates an error decoding the RPC response.
  79. ///
  80. /// This is typically due to some sort of unexpected response value from the server.
  81. ///
  82. /// See the `NSUnderlyingError` value in the `NSError.userInfo` dictionary for details.
  83. ///
  84. /// See the `userInfoDeserializedResponseKey` value in the `NSError.userInfo` dictionary.
  85. /// The deserialized representation of the response will be associated with this key.
  86. case RPCResponseDecodingError = 5
  87. }