File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change
1
+ # Unreleased
2
+ - [ added] Provide server errors via the ` NSUnderlyingErrorKey ` .
3
+
1
4
# 10.5.0
2
5
- [ added] Added Storage API to limit upload chunk size. (#10137 )
3
6
- [ fixed] Run ` pod update ` or ` File -> Packages -> Update to latest Packages ` to update the ` GTMSessionFetcher ` dependency to at least version ` 3.1.0 ` .
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ public let StorageErrorDomain: String = "FIRStorageErrorDomain"
58
58
errorDictionary [ " ResponseErrorDomain " ] = serverError. domain
59
59
errorDictionary [ " ResponseErrorCode " ] = serverError. code
60
60
errorDictionary [ " bucket " ] = ref. path. bucket
61
+ errorDictionary [ NSUnderlyingErrorKey] = serverError
61
62
62
63
if let object = ref. path. object {
63
64
errorDictionary [ " object " ] = object
Original file line number Diff line number Diff line change @@ -55,7 +55,12 @@ import XCTest
55
55
_ = try await ref. delete ( )
56
56
} catch {
57
57
caughtError = true
58
- XCTAssertEqual ( ( error as NSError ) . code, StorageErrorCode . objectNotFound. rawValue)
58
+ let nsError = error as NSError
59
+ XCTAssertEqual ( nsError. code, StorageErrorCode . objectNotFound. rawValue)
60
+ XCTAssertEqual ( nsError. userInfo [ " ResponseErrorCode " ] as? Int , 404 )
61
+ let underlyingError = try XCTUnwrap ( nsError. userInfo [ NSUnderlyingErrorKey] as? NSError )
62
+ XCTAssertEqual ( underlyingError. code, 404 )
63
+ XCTAssertEqual ( underlyingError. domain, " com.google.HTTPStatus " )
59
64
}
60
65
XCTAssertTrue ( caughtError)
61
66
}
@@ -132,8 +137,11 @@ import XCTest
132
137
do {
133
138
_ = try await ref. putFileAsync ( from: fileURL)
134
139
XCTFail ( " Unexpected success from putFile of a directory " )
135
- } catch StorageError . unknown {
136
- XCTAssertTrue ( true )
140
+ } catch let StorageError . unknown( reason) {
141
+ XCTAssertTrue ( reason. starts ( with: " File at URL: " ) )
142
+ XCTAssertTrue ( reason. hasSuffix (
143
+ " is not reachable. Ensure file URL is not a directory, symbolic link, or invalid url. "
144
+ ) )
137
145
} catch {
138
146
XCTFail ( " error failed to convert to StorageError.unknown " )
139
147
}
You can’t perform that action at this time.
0 commit comments