@@ -8,8 +8,11 @@ public struct MultipartResponseParsingInterceptor: ApolloInterceptor {
8
8
9
9
public enum ParsingError : Error , LocalizedError , Equatable {
10
10
case noResponseToParse
11
+ @available ( * , deprecated, message: " Use the more specific `missingMultipartBoundary` and `invalidMultipartProtocol` errors instead. " )
11
12
case cannotParseResponse
12
13
case cannotParseResponseData
14
+ case missingMultipartBoundary
15
+ case invalidMultipartProtocol
13
16
14
17
public var errorDescription : String ? {
15
18
switch self {
@@ -19,6 +22,10 @@ public struct MultipartResponseParsingInterceptor: ApolloInterceptor {
19
22
return " The response data could not be parsed. "
20
23
case . cannotParseResponseData:
21
24
return " The response data could not be parsed. "
25
+ case . missingMultipartBoundary:
26
+ return " Missing multipart boundary in the response 'content-type' header. "
27
+ case . invalidMultipartProtocol:
28
+ return " Missing, or unknown, multipart specification protocol in the response 'content-type' header. "
22
29
}
23
30
}
24
31
}
@@ -61,13 +68,22 @@ public struct MultipartResponseParsingInterceptor: ApolloInterceptor {
61
68
62
69
let multipartComponents = response. httpResponse. multipartHeaderComponents
63
70
71
+ guard let boundary = multipartComponents. boundary else {
72
+ chain. handleErrorAsync (
73
+ ParsingError . missingMultipartBoundary,
74
+ request: request,
75
+ response: response,
76
+ completion: completion
77
+ )
78
+ return
79
+ }
80
+
64
81
guard
65
- let boundary = multipartComponents. boundary,
66
82
let `protocol` = multipartComponents. protocol,
67
83
let parser = Self . responseParsers [ `protocol`]
68
84
else {
69
85
chain. handleErrorAsync (
70
- ParsingError . cannotParseResponse ,
86
+ ParsingError . invalidMultipartProtocol ,
71
87
request: request,
72
88
response: response,
73
89
completion: completion
0 commit comments