@@ -179,7 +179,7 @@ class HttpRequestHandler {
179179 } catch {
180180 // Explicitly reject if the http request body was not set successfully,
181181 // so as to not send a known malformed request, and to provide the developer with additional context.
182- call. reject ( " Error " , " REQUEST " , error, [ : ] )
182+ call. reject ( error . localizedDescription , " http request " , error, [ : ] )
183183 return
184184 }
185185 }
@@ -189,6 +189,8 @@ class HttpRequestHandler {
189189 let task = urlSession. dataTask ( with: urlRequest) { ( data, response, error) in
190190 urlSession. invalidateAndCancel ( ) ;
191191 if error != nil {
192+ CAPLog . print ( " Error on request " , String ( describing: data) , String ( describing: response) , String ( describing: error) )
193+ call. reject ( error!. localizedDescription, " http request " , error, [ : ] )
192194 return
193195 }
194196
@@ -236,7 +238,7 @@ class HttpRequestHandler {
236238 let task = URLSession . shared. uploadTask ( with: urlRequest, from: form) { ( data, response, error) in
237239 if error != nil {
238240 CAPLog . print ( " Error on upload file " , String ( describing: data) , String ( describing: response) , String ( describing: error) )
239- call. reject ( " Error " , " UPLOAD " , error, [ : ] )
241+ call. reject ( error! . localizedDescription , " http upload " , error, [ : ] )
240242 return
241243 }
242244 let type = ResponseType ( rawValue: responseType) ?? . default
@@ -274,12 +276,12 @@ class HttpRequestHandler {
274276 func handleDownload( downloadLocation: URL ? , response: URLResponse ? , error: Error ? ) {
275277 if error != nil {
276278 CAPLog . print ( " Error on download file " , String ( describing: downloadLocation) , String ( describing: response) , String ( describing: error) )
277- call. reject ( " Error " , " DOWNLOAD " , error, [ : ] )
279+ call. reject ( error! . localizedDescription , " http download " , error, [ : ] )
278280 return
279281 }
280282
281283 guard let location = downloadLocation else {
282- call. reject ( " Unable to get file after downloading " )
284+ call. reject ( " Unable to get file after downloading " , " http download " )
283285 return
284286 }
285287
@@ -298,7 +300,7 @@ class HttpRequestHandler {
298300 try fileManager. moveItem ( at: location, to: dest)
299301 call. resolve ( [ " path " : dest. absoluteString] )
300302 } catch let e {
301- call. reject ( " Unable to download file " , " DOWNLOAD " , e)
303+ call. reject ( " Unable to download file: \( e . localizedDescription ) " , " http download " , e)
302304 return
303305 }
304306
0 commit comments