FIRStorageErrors.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <FirebaseStorage/FIRStorageConstants.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. @class FIRStorageReference;
  19. /**
  20. * Adds wrappers for common Firebase Storage errors (including creating errors from GCS errors).
  21. * For more information on unwrapping GCS errors, see the GCS errors docs:
  22. * https://cloud.google.com/storage/docs/json_api/v1/status-codes
  23. * This is never publicly exposed to end developers (as they will simply see an NSError).
  24. */
  25. @interface FIRStorageErrors : NSObject
  26. /**
  27. * Creates a Firebase Storage error from a specific FIRStorageErrorCode.
  28. */
  29. + (NSError *)errorWithCode:(FIRStorageErrorCode)code;
  30. /**
  31. * Creates a Firebase Storage error from a specific FIRStorageErrorCode while adding
  32. * custom info from an optionally provided info dictionary.
  33. */
  34. + (NSError *)errorWithCode:(FIRStorageErrorCode)code
  35. infoDictionary:(nullable NSDictionary *)dictionary;
  36. /**
  37. * Creates a Firebase Storage error from a specific GCS error and FIRStorageReference.
  38. * @param error Server error to wrap and return as a Firebase Storage error.
  39. * @param reference FIRStorageReference which provides context about the request being made.
  40. * @return Returns a Firebase Storage error, or nil if no error is provided.
  41. */
  42. + (nullable NSError *)errorWithServerError:(nullable NSError *)error
  43. reference:(nullable FIRStorageReference *)reference;
  44. /**
  45. * Creates a Firebase Storage error from an invalid request.
  46. *
  47. * @param request The NSData representation of the invalid user request.
  48. * @return Returns the corresponding Firebase Storage error.
  49. */
  50. + (NSError *)errorWithInvalidRequest:(NSData *)request;
  51. /**
  52. * Creates a Firebase Storage error with a custom error message.
  53. *
  54. * @param errorMessage A custom error message.
  55. * @return Returns the corresponding Firebase Storage error.
  56. */
  57. + (NSError *)errorWithCustomMessage:(NSString *)errorMessage;
  58. @end
  59. NS_ASSUME_NONNULL_END