Skip to content

Commit

Permalink
fix(ios/android): better http error handling (#6208)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jan 17, 2023
1 parent 2d9f058 commit 7d4d70a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public void run() {
JSObject response = HttpRequestHandler.request(call, httpMethod);
call.resolve(response);
} catch (Exception e) {
System.out.println(e.toString());
call.reject(e.getClass().getSimpleName(), e);
call.reject(e.getLocalizedMessage(), e.getClass().getSimpleName(), e);
}
}
};
Expand Down
5 changes: 3 additions & 2 deletions ios/Capacitor/Capacitor/Plugins/HttpRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class HttpRequestHandler {
} catch {
// Explicitly reject if the http request body was not set successfully,
// so as to not send a known malformed request, and to provide the developer with additional context.
call.reject("Error", "REQUEST", error, [:])
call.reject(error.localizedDescription, (error as NSError).domain, error, nil)
return
}
}
Expand All @@ -180,7 +180,8 @@ class HttpRequestHandler {
let task = urlSession.dataTask(with: urlRequest) { (data, response, error) in
urlSession.invalidateAndCancel()

if error != nil {
if let error = error {
call.reject(error.localizedDescription, (error as NSError).domain, error, nil)
return
}

Expand Down

0 comments on commit 7d4d70a

Please sign in to comment.