Closed jurgowski closed 5 months ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Thanks for the report. We'll take a look in the next few weeks. In the meantime, let us know if you find anything more - and we'd be interested in a PR.
Errors from the server should actually be wrapped by func error(withServerError serverError: NSError, ref: StorageReference)
. if the error is not a server error, all the context should be in the Swift error. More examples and context in #10913. If you're still blocked, we may need a reproducible example.
Sorry for the delayed response and thanks for adding a PR!
So the Error
that is created via error(withServerError:..
is actually great - it has all the info needed since it copies over the userInfo
dictionary from the server Error
. #10913 might actually not be necessary as all the info is carried over.
The loss in information comes when the wrapped Error
is converted to the new StorageError
in the getResultCallback
method. I think a fix here would be to just not call .swiftConvert(objcError:
. The case where there is no error in the callback can potentially leverage the new StorageError
error type introduced.
I was actually able to work around this quite easily (staying in an async Swift context) by just using the sync APIs and wrapping them with withCheckedThrowingContinuation
myself. This threw the wrapped error(withServerError
error as opposed to the StorageError
and had all the info needed in my logging to debug.
TL'DR Server Error -> Wrapped Error -> StorageError. The first two are great - the third is missing info.
Thanks @jurgowski. I like the ideas of using CustomNSError
and/or dropping swiftConvert
. However, I'm not sure that can be done without breaking the ability to catch individual StorageErrors
so it would be a breaking change. As a result, I've marked this for our next breaking change release.
I agree that the underlyingError
change isn't absolutely necessary but it should be non-breaking and provide the underlying server Error in a more standard way.
I guess the main use case for CustomNSError
is to make Swift errors easy to deal with in Obj-C code without custom bridging. It seems like in this case, the errors are coming from Obj-C and StorageError
is a newly introduced error type (I didn't realize this when I first opened the issue).
I agree that I don't think there is a way to make a change here that doesn't alter current behavior since StorageError
is an enum.. However, I would expect that anyone catching StorageError
is probably catching all errors generically. It may be possible to use the error directly in the failure case of the Result
in getResultCallback
(without converting it to StorageError
via swiftConvert
). As long as StorageError
isn't deleted, things would still compile.
Description
One of my TestFlight users consistently gets an error when using the FirebaseStorage API:
StorageReference.writeAsync()
Logging this error provides little insights since the localizedDescription is
The operation couldn’t be completed. (FirebaseStorage.StorageError error 0.)
Unpacking the error case and logging the
.unknown(String)
producesAn unknown error occurred, please check the server response.
The server response isn't on the error however since its lost when the Objective-C
NSError
is converted the Swift enum viaswiftConvert(objcError:)
.Would it be possible to instead make
StorageError
conform toCustomNSError
and expose theuserInfo
in Swift? Would love to debug this without rewriting a significant portion of my code in Objective-C.Reproducing the issue
Trying to figure this out myself.
Firebase SDK Version
10.5.0
Xcode Version
14.2
Installation Method
Swift Package Manager
Firebase Product(s)
Storage
Targeted Platforms
iOS
Relevant Log Output
No response
If using Swift Package Manager, the project's Package.resolved
If using CocoaPods, the project's Podfile.lock
Expand
Podfile.lock
snippet```yml Replace this line with the contents of your Podfile.lock! ```