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.

504 lines
25 KiB

6 years ago
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FIRPhoneAuthCredential;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** @class FIRAuthErrorUtils
  20. @brief Utility class used to construct @c NSError instances.
  21. */
  22. @interface FIRAuthErrorUtils : NSObject
  23. /** @fn RPCRequestEncodingErrorWithUnderlyingError
  24. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeRPCRequestEncodingError
  25. code and a populated @c NSUnderlyingErrorKey in the @c NSError.userInfo dictionary.
  26. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  27. @remarks This error is used when an @c FIRAuthRPCRequest.unencodedHTTPRequestBodyWithError:
  28. invocation returns an error. The error returned is wrapped in this internal error code.
  29. */
  30. + (NSError *)RPCRequestEncodingErrorWithUnderlyingError:(NSError *)underlyingError;
  31. /** @fn JSONSerializationErrorForUnencodableType
  32. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeJSONSerializationError code.
  33. @remarks This error is used when an @c NSJSONSerialization.isValidJSONObject: check fails, not
  34. for when an error is returned from @c NSJSONSerialization.dataWithJSONObject:options:error:.
  35. */
  36. + (NSError *)JSONSerializationErrorForUnencodableType;
  37. /** @fn JSONSerializationErrorWithUnderlyingError:
  38. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeJSONSerializationError code, and the
  39. @c underlyingError as the @c NSUnderlyingErrorKey value in the @c NSError.userInfo
  40. dictionary.
  41. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  42. @remarks This error is used when an invocation of
  43. @c NSJSONSerialization.dataWithJSONObject:options:error: returns an error.
  44. */
  45. + (NSError *)JSONSerializationErrorWithUnderlyingError:(NSError *)underlyingError;
  46. /** @fn networkErrorWithUnderlyingError:
  47. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNetworkError code, and the
  48. @c underlyingError as the @c NSUnderlyingErrorKey value in the @c NSError.userInfo
  49. dictionary.
  50. @param underlyingError The value of the @c NSUnderlyingErrorKey key. Should be the error from
  51. GTM.
  52. @remarks This error is used when a network request results in an error, and no body data was
  53. returned.
  54. */
  55. + (NSError *)networkErrorWithUnderlyingError:(NSError *)underlyingError;
  56. /** @fn unexpectedErrorResponseWithUnderlyingError:
  57. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNetworkError code, and the
  58. @c underlyingError as the @c NSUnderlyingErrorKey value.
  59. @param data The value of the @c FIRAuthErrorUserInfoDataKey key in the @c NSError.userInfo
  60. dictionary.
  61. @param underlyingError The value of the @c NSUnderlyingErrorKey key in the @c NSError.userInfo
  62. dictionary.
  63. @remarks This error is used when a network request results in an error, and unserializable body
  64. data was returned.
  65. */
  66. + (NSError *)unexpectedErrorResponseWithData:(NSData *)data
  67. underlyingError:(NSError *)underlyingError;
  68. /** @fn unexpectedErrorResponseWithDeserializedResponse:
  69. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedErrorResponse
  70. code, and a populated @c FIRAuthErrorUserInfoDeserializedResponseKey key in the
  71. @c NSError.userInfo dictionary.
  72. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  73. @remarks This error is used when a network request results in an error, and the body data was
  74. deserializable as JSON, but couldn't be decoded as an error.
  75. */
  76. + (NSError *)unexpectedErrorResponseWithDeserializedResponse:(id)deserializedResponse;
  77. /** @fn unexpectedResponseWithData:underlyingError:
  78. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedResponse
  79. code, and a populated @c FIRAuthErrorUserInfoDataKey key in the @c NSError.userInfo
  80. dictionary.
  81. @param data The value of the @c FIRAuthErrorUserInfoDataKey key in the @c NSError.userInfo
  82. dictionary.
  83. @param underlyingError The value of the @c NSUnderlyingErrorKey key in the @c NSError.userInfo
  84. dictionary.
  85. @remarks This error is used when a network request is apparently successful, but the body data
  86. couldn't be deserialized as JSON.
  87. */
  88. + (NSError *)unexpectedResponseWithData:(NSData *)data
  89. underlyingError:(NSError *)underlyingError;;
  90. /** @fn unexpectedResponseWithDeserializedResponse:
  91. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedResponse
  92. code, and a populated @c FIRAuthErrorUserInfoDeserializedResponseKey key in the
  93. @c NSError.userInfo dictionary.
  94. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  95. @remarks This error is used when a network request is apparently successful, the body data was
  96. successfully deserialized as JSON, but the JSON wasn't a dictionary.
  97. */
  98. + (NSError *)unexpectedResponseWithDeserializedResponse:(id)deserializedResponse;
  99. /** @fn unexpectedResponseWithDeserializedResponse:underlyingError:
  100. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedResponse
  101. code, and populated @c FIRAuthErrorUserInfoDeserializedResponseKey and
  102. @c NSUnderlyingErrorKey keys in the @c NSError.userInfo dictionary.
  103. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  104. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  105. @remarks This error is used when a network request was apparently successful, the body data was
  106. successfully deserialized as JSON, but the data type of the response was unexpected.
  107. */
  108. + (NSError *)unexpectedResponseWithDeserializedResponse:(nullable id)deserializedResponse
  109. underlyingError:(NSError *)underlyingError;
  110. /** @fn RPCResponseDecodingErrorWithDeserializedResponse:underlyingError:
  111. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeRPCResponseDecodingError
  112. code, and populated @c FIRAuthErrorUserInfoDeserializedResponseKey and
  113. @c NSUnderlyingErrorKey keys in the @c NSError.userInfo dictionary.
  114. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  115. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  116. @remarks This error is used when an invocation of @c FIRAuthRPCResponse.setWithDictionary:error:
  117. resulted in an error.
  118. */
  119. + (NSError *)RPCResponseDecodingErrorWithDeserializedResponse:(id)deserializedResponse
  120. underlyingError:(NSError *)underlyingError;
  121. /** @fn emailAlreadyInUseErrorWithEmail:
  122. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeEmailExists code.
  123. @param email The email address that is already in use.
  124. @return The NSError instance associated with the given FIRAuthError.
  125. */
  126. + (NSError *)emailAlreadyInUseErrorWithEmail:(nullable NSString *)email;
  127. /** @fn userDisabledErrorWithMessageWithMessage:
  128. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserDisabled code.
  129. @param message Error message from the backend, if any.
  130. @return The NSError instance associated with the given FIRAuthError.
  131. */
  132. + (NSError *)userDisabledErrorWithMessage:(nullable NSString *)message;
  133. /** @fn wrongPasswordErrorWithMessage:
  134. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWrongPassword code.
  135. @param message Error message from the backend, if any.
  136. @return The NSError instance associated with the given FIRAuthError.
  137. */
  138. + (NSError *)wrongPasswordErrorWithMessage:(nullable NSString *)message;
  139. /** @fn tooManyRequestsErrorWithMessage:
  140. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeTooManyRequests Code.
  141. @param message Error message from the backend, if any.
  142. @return The NSError instance associated with the given FIRAuthError.
  143. */
  144. + (NSError *)tooManyRequestsErrorWithMessage:(nullable NSString *)message;
  145. /** @fn invalidCustomTokenErrorWithMessage:
  146. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidCustomToken code.
  147. @param message Error message from the backend, if any.
  148. @return The NSError instance associated with the given FIRAuthError.
  149. */
  150. + (NSError *)invalidCustomTokenErrorWithMessage:(nullable NSString *)message;
  151. /** @fn customTokenMistmatchErrorWithMessage:
  152. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeCustomTokenMismatch code.
  153. @param message Error message from the backend, if any.
  154. @return The NSError instance associated with the given FIRAuthError.
  155. */
  156. + (NSError *)customTokenMistmatchErrorWithMessage:(nullable NSString *)message;
  157. /** @fn invalidCredentialErrorWithMessage:
  158. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidCredential code.
  159. @param message Error message from the backend, if any.
  160. @return The NSError instance associated with the given FIRAuthError.
  161. */
  162. + (NSError *)invalidCredentialErrorWithMessage:(nullable NSString *)message;
  163. /** @fn requiresRecentLoginError
  164. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeRequiresRecentLogin code.
  165. @param message Error message from the backend, if any.
  166. @return The NSError instance associated with the given FIRAuthError.
  167. */
  168. + (NSError *)requiresRecentLoginErrorWithMessage:(nullable NSString *)message;
  169. /** @fn invalidUserTokenErrorWithMessage:
  170. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidUserToken code.
  171. @param message Error message from the backend, if any.
  172. @return The NSError instance associated with the given FIRAuthError.
  173. */
  174. + (NSError *)invalidUserTokenErrorWithMessage:(nullable NSString *)message;
  175. /** @fn invalidEmailErrorWithMessage:
  176. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidEmail code.
  177. @param message Error message from the backend, if any.
  178. @return The NSError instance associated with the given FIRAuthError.
  179. */
  180. + (NSError *)invalidEmailErrorWithMessage:(nullable NSString *)message;
  181. /** @fn accountExistsWithDifferentCredentialErrorWithEmail:
  182. @brief Constructs an @c NSError with the @c FIRAuthErrorAccountExistsWithDifferentCredential
  183. code.
  184. @param Email The email address that is already associated with an existing account
  185. @return The NSError instance associated with the given FIRAuthError.
  186. */
  187. + (NSError *)accountExistsWithDifferentCredentialErrorWithEmail:(nullable NSString *)Email;
  188. /** @fn providerAlreadyLinkedErrorWithMessage:
  189. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeProviderAlreadyLinked code.
  190. @return The NSError instance associated with the given FIRAuthError.
  191. */
  192. + (NSError *)providerAlreadyLinkedError;
  193. /** @fn noSuchProviderError
  194. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNoSuchProvider code.
  195. @return The NSError instance associated with the given FIRAuthError.
  196. */
  197. + (NSError *)noSuchProviderError;
  198. /** @fn userTokenExpiredErrorWithMessage:
  199. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserTokenExpired code.
  200. @param message Error message from the backend, if any.
  201. @return The NSError instance associated with the given FIRAuthError.
  202. */
  203. + (NSError *)userTokenExpiredErrorWithMessage:(nullable NSString *)message;
  204. /** @fn userNotFoundErrorWithMessage:
  205. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserNotFound code.
  206. @param message Error message from the backend, if any.
  207. @return The NSError instance associated with the given FIRAuthError.
  208. */
  209. + (NSError *)userNotFoundErrorWithMessage:(nullable NSString *)message;
  210. /** @fn invalidLocalAPIKeyErrorWithMessage:
  211. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidAPIKey code.
  212. @return The NSError instance associated with the given FIRAuthError.
  213. */
  214. + (NSError *)invalidAPIKeyError;
  215. /** @fn userMismatchError
  216. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserMismatch code.
  217. @return The NSError instance associated with the given FIRAuthError.
  218. */
  219. + (NSError *)userMismatchError;
  220. /** @fn credentialAlreadyInUseErrorWithMessage:
  221. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeCredentialAlreadyInUse code.
  222. @param message Error message from the backend, if any.
  223. @param credential Auth credential to be added to the Error User Info dictionary.
  224. @return The NSError instance associated with the given FIRAuthError.
  225. */
  226. + (NSError *)credentialAlreadyInUseErrorWithMessage:(nullable NSString *)message
  227. credential:(nullable FIRPhoneAuthCredential *)credential;
  228. /** @fn operationNotAllowedErrorWithMessage:
  229. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeOperationNotAllowed code.
  230. @param message Error message from the backend, if any.
  231. @return The NSError instance associated with the given FIRAuthError.
  232. */
  233. + (NSError *)operationNotAllowedErrorWithMessage:(nullable NSString *)message;
  234. /** @fn weakPasswordErrorWithServerResponseReason:
  235. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWeakPassword code.
  236. @param serverResponseReason A more detailed explanation string from server response.
  237. @return The NSError instance associated with the given FIRAuthError.
  238. */
  239. + (NSError *)weakPasswordErrorWithServerResponseReason:(NSString *)serverResponseReason;
  240. /** @fn appNotAuthorizedError
  241. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeAppNotAuthorized code.
  242. @return The NSError instance associated with the given FIRAuthError.
  243. */
  244. + (NSError *)appNotAuthorizedError;
  245. /** @fn expiredActionCodeErrorWithMessage:
  246. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeExpiredActionCode code.
  247. @param message Error message from the backend, if any.
  248. @return The NSError instance associated with the given FIRAuthError.
  249. */
  250. + (NSError *)expiredActionCodeErrorWithMessage:(nullable NSString *)message;
  251. /** @fn invalidActionCodeErrorWithMessage:
  252. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidActionCode code.
  253. @param message Error message from the backend, if any.
  254. @return The NSError instance associated with the given FIRAuthError.
  255. */
  256. + (NSError *)invalidActionCodeErrorWithMessage:(nullable NSString *)message;
  257. /** @fn invalidMessagePayloadError:
  258. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidMessagePayload code.
  259. @param message Error message from the backend, if any.
  260. @return The NSError instance associated with the given FIRAuthError.
  261. */
  262. + (NSError *)invalidMessagePayloadErrorWithMessage:(nullable NSString *)message;
  263. /** @fn invalidSenderErrorWithMessage:
  264. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidSender code.
  265. @param message Error message from the backend, if any.
  266. @return The NSError instance associated with the given FIRAuthError.
  267. */
  268. + (NSError *)invalidSenderErrorWithMessage:(nullable NSString *)message;
  269. /** @fn invalidRecipientEmailError:
  270. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidRecipientEmail code.
  271. @param message Error message from the backend, if any.
  272. @return The NSError instance associated with the given FIRAuthError.
  273. */
  274. + (NSError *)invalidRecipientEmailErrorWithMessage:(nullable NSString *)message;
  275. /** @fn missingIosBundleIDErrorWithMessage:
  276. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingIosBundleID code.
  277. @param message Error message from the backend, if any.
  278. @return The NSError instance associated with the given FIRAuthError.
  279. */
  280. + (NSError *)missingIosBundleIDErrorWithMessage:(nullable NSString *)message;
  281. /** @fn missingAndroidPackageNameErrorWithMessage:
  282. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingAndroidPackageName code.
  283. @param message Error message from the backend, if any.
  284. @return The NSError instance associated with the given FIRAuthError.
  285. */
  286. + (NSError *)missingAndroidPackageNameErrorWithMessage:(nullable NSString *)message;
  287. /** @fn unauthorizedDomainErrorWithMessage:
  288. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUnauthorizedDomain code.
  289. @param message Error message from the backend, if any.
  290. @return The NSError instance associated with the given FIRAuthError.
  291. */
  292. + (NSError *)unauthorizedDomainErrorWithMessage:(nullable NSString *)message;
  293. /** @fn invalidContinueURIErrorWithMessage:
  294. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidContinueURI code.
  295. @param message Error message from the backend, if any.
  296. @return The NSError instance associated with the given FIRAuthError.
  297. */
  298. + (NSError *)invalidContinueURIErrorWithMessage:(nullable NSString *)message;
  299. /** @fn missingContinueURIErrorWithMessage:
  300. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingContinueURI code.
  301. @param message Error message from the backend, if any.
  302. @return The NSError instance associated with the given FIRAuthError.
  303. */
  304. + (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message;
  305. /** @fn missingEmailErrorWithMessage
  306. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingEmail code.
  307. @param message Error message from the backend, if any.
  308. @return The NSError instance associated with the given FIRAuthError.
  309. */
  310. + (NSError *)missingEmailErrorWithMessage:(nullable NSString *)message;
  311. /** @fn missingPhoneNumberErrorWithMessage:
  312. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingPhoneNumber code.
  313. @param message Error message from the backend, if any.
  314. @return The NSError instance associated with the given FIRAuthError.
  315. */
  316. + (NSError *)missingPhoneNumberErrorWithMessage:(nullable NSString *)message;
  317. /** @fn invalidPhoneNumberErrorWithMessage:
  318. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidPhoneNumber code.
  319. @param message Error message from the backend, if any.
  320. @return The NSError instance associated with the given FIRAuthError.
  321. */
  322. + (NSError *)invalidPhoneNumberErrorWithMessage:(nullable NSString *)message;
  323. /** @fn missingVerificationCodeErrorWithMessage:
  324. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingVerificationCode code.
  325. @param message Error message from the backend, if any.
  326. @return The NSError instance associated with the given FIRAuthError.
  327. */
  328. + (NSError *)missingVerificationCodeErrorWithMessage:(nullable NSString *)message;
  329. /** @fn invalidVerificationCodeErrorWithMessage:
  330. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidVerificationCode code.
  331. @param message Error message from the backend, if any.
  332. @return The NSError instance associated with the given FIRAuthError.
  333. */
  334. + (NSError *)invalidVerificationCodeErrorWithMessage:(nullable NSString *)message;
  335. /** @fn missingVerificationIDErrorWithMessage:
  336. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingVerificationID code.
  337. @param message Error message from the backend, if any.
  338. @return The NSError instance associated with the given FIRAuthError.
  339. */
  340. + (NSError *)missingVerificationIDErrorWithMessage:(nullable NSString *)message;
  341. /** @fn invalidVerificationIDErrorWithMessage:
  342. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidVerificationID code.
  343. @param message Error message from the backend, if any.
  344. @return The NSError instance associated with the given FIRAuthError.
  345. */
  346. + (NSError *)invalidVerificationIDErrorWithMessage:(nullable NSString *)message;
  347. /** @fn sessionExpiredErrorWithMessage:
  348. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeSessionExpired code.
  349. @param message Error message from the backend, if any.
  350. @return The NSError instance associated with the given FIRAuthError.
  351. */
  352. + (NSError *)sessionExpiredErrorWithMessage:(nullable NSString *)message;
  353. /** @fn missingAppCredentialWithMessage:
  354. @brief Constructs an @c NSError with the @c FIRAuthErrorMissingCredential code.
  355. @param message Error message from the backend, if any.
  356. @return The NSError instance associated with the given FIRAuthError.
  357. */
  358. + (NSError *)missingAppCredentialWithMessage:(nullable NSString *)message;
  359. /** @fn invalidAppCredentialWithMessage:
  360. @brief Constructs an @c NSError with the @c FIRAuthErrorInvalidCredential code.
  361. @param message Error message from the backend, if any.
  362. @return The NSError instance associated with the given FIRAuthError.
  363. */
  364. + (NSError *)invalidAppCredentialWithMessage:(nullable NSString *)message;
  365. /** @fn quotaExceededErrorWithMessage:
  366. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeQuotaExceeded code.
  367. @param message Error message from the backend, if any.
  368. @return The NSError instance associated with the given FIRAuthError.
  369. */
  370. + (NSError *)quotaExceededErrorWithMessage:(nullable NSString *)message;
  371. /** @fn missingAppTokenErrorWithUnderlyingError
  372. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingAppToken code.
  373. @param underlyingError The underlying error, if any.
  374. @return The NSError instance associated with the given FIRAuthError.
  375. */
  376. + (NSError *)missingAppTokenErrorWithUnderlyingError:(nullable NSError *)underlyingError;
  377. /** @fn notificationNotForwardedError
  378. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNotificationNotForwarded code.
  379. @return The NSError instance associated with the given FIRAuthError.
  380. */
  381. + (NSError *)notificationNotForwardedError;
  382. /** @fn appNotVerifiedErrorWithMessage:
  383. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeAppNotVerified code.
  384. @param message Error message from the backend, if any.
  385. @return The NSError instance associated with the given FIRAuthError.
  386. */
  387. + (NSError *)appNotVerifiedErrorWithMessage:(nullable NSString *)message;
  388. /** @fn captchaCheckFailedErrorWithMessage:
  389. @brief Constructs an @c NSError with the @c FIRAuthErrorCaptchaCheckFailed code.
  390. @param message Error message from the backend, if any.
  391. @return The NSError instance associated with the given FIRAuthError.
  392. */
  393. + (NSError *)captchaCheckFailedErrorWithMessage:(nullable NSString *)message;
  394. /** @fn webContextAlreadyPresentedErrorWithMessage:
  395. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWebContextAlreadyPresented code.
  396. @param message Error message from the backend, if any.
  397. @return The NSError instance associated with the given FIRAuthError.
  398. */
  399. + (NSError *)webContextAlreadyPresentedErrorWithMessage:(nullable NSString *)message;
  400. /** @fn webContextCancelledErrorWithMessage:
  401. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWebContextCancelled code.
  402. @param message Error message from the backend, if any.
  403. @return The NSError instance associated with the given FIRAuthError.
  404. */
  405. + (NSError *)webContextCancelledErrorWithMessage:(nullable NSString *)message;
  406. /** @fn appVerificationUserInteractionFailureWithReason:
  407. @brief Constructs an @c NSError with the @c
  408. FIRAuthErrorCodeAppVerificationUserInteractionFailure code.
  409. @param reason Reason for error, returned via URL response.
  410. @return The NSError instance associated with the given FIRAuthError.
  411. */
  412. + (NSError *)appVerificationUserInteractionFailureWithReason:(NSString *)reason;
  413. /** @fn URLResponseErrorWithCode:message:
  414. @brief Constructs an @c NSError with the code and message provided.
  415. @param message Error message from the backend, if any.
  416. @return The nullable NSError instance associated with the given error message, if one is found.
  417. */
  418. + (NSError *)URLResponseErrorWithCode:(NSString *)code message:(nullable NSString *)message;
  419. /** @fn nullUserErrorWithMessage:
  420. @brief Constructs an @c NSError with the code and message provided.
  421. @param message Error message from the backend, if any.
  422. @return The nullable NSError instance associated with the given error message, if one is found.
  423. */
  424. + (NSError *)nullUserErrorWithMessage:(nullable NSString *)message;
  425. /** @fn keychainErrorWithFunction:status:
  426. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeKeychainError code.
  427. @param keychainFunction The keychain function which was invoked and yielded an unexpected
  428. response. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo
  429. dictionary will contain a string partially comprised of this value.
  430. @param status The response status from the invoked keychain function. The
  431. @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain
  432. a string partially comprised of this value.
  433. */
  434. + (NSError *)keychainErrorWithFunction:(NSString *)keychainFunction status:(OSStatus)status;
  435. @end
  436. NS_ASSUME_NONNULL_END