Android webview not throw detailed error message when fetch failure - webview

I use fetch in try catch in Android webview, when the url has network issue or sslerror, I try to show the detailed error message about the reason, but the error only show "TypeError: Failed to fetch". Where to get the detailed error message?
Example code:
try {
await fetch("https://xxx");
} catch(error) {
console.log(error);
}

Related

Firebase StorageReference.listAll() completion handler unexpectedly fires twice in error case

I'm writing an iOS app and I want to list all the files in a Firebase Storage folder. If I understand correctly, the way to do this is to use the StorageReference.listAll() function, which takes a completion handler as its parameter. The problem is that in an error case - for example if the user is offline - this handler fires twice: the first time with an error, the second time without. Here's my code, simplified for the purposes of this question:
let storageReference = Storage.storage().reference().child(userID)
storageReference.listAll { (result, error) in
print("handler fires")
if let error = error {
print("error")
} else {
print("no error")
}
}
In the regular case, this outputs "handler fires", "no error" which is what one would expect. If the user is offline, however, it outputs "handler fires", "error", "handler fires", "no error", which seems strange. Does anyone know why the handler is firing twice in the error case, and why the second of these firings reports no error?
Here is the full error log:
handler fires
Error description: Error Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response." UserInfo={_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSErrorFailingURLStringKey=https://firebasestorage.googleapis.com/v0/b/xxx.appspot.com/o?prefix=xxx/&delimiter=/, NSUnderlyingError=0x282dcdc80 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLKey=https://firebasestorage.googleapis.com/v0/b/xxx.appspot.com/o?prefix=xxx/&delimiter=/,_NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDataTask <1487E789-1446-42FF-9F5F-EEF8AD4370E1>.<4>"), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <1487E789-1446-42FF-9F5F-EEF8AD4370E1>.<4>, kGTMSessionFetcherElapsedIntervalWithRetriesKey=14.007386088371277, kGTMSessionFetcherNumberOfRetriesDoneKey=3, ResponseErrorDomain=NSURLErrorDomain, bucket=xxx.appspot.com, object=xxx, ResponseErrorCode=-1009, NSLocalizedDescription=An unknown error occurred, please check the server response.}
handler fires
No error

Webrtc error while initiating addIceCandidate

I am trying to initiate peer to peer connection in webrtc. I am using signalr as signaling server. I am getting error in all the browser when adding ice candidate. Below is the error and line of code. Please let me know how can i fix this.
Error in Firefox:
InvalidStateError: No remoteDescription.
Error in Chrome:
DOMException: Failed to execute 'addIceCandidate' on
'RTCPeerConnection': Error processing ICE candidate
Code:
if (signal.ice) {
console.log(signal.ice);
peerConnections.addIceCandidate(new RTCIceCandidate(signal.ice)).catch(errorHandler.message);
}
You don't need to build a new ice candidate object. Just adding signal.ice as ice candidate is enough. Here is the example from the official webrtc guide
signalingChannel.addEventListener('message', async message => {
if (message.iceCandidate) {
try {
await peerConnection.addIceCandidate(message.iceCandidate);
} catch (e) {
console.error('Error adding received ice candidate', e);
}
}
});

How to detect errors from GraphServiceClient SendMail

I am using the following code to send email for the logged in user.
await _graphClient.Me.SendMail(email, true).Request().PostAsync();
Initially it was executing be no email was sent. After poking around I figured out that a permission was not set. Unfortunately the try..catch around it was not tripped. My questions is if there is a way of detecting that an error occurred with this call.
Regarding
Unfortunately the try..catch around it was not tripped.
PostAsync() method should throw a ServiceException on error.
For example, in case of missing permissions:
try
{
await graphClient.Users[userId].SendMail(message).Request().PostAsync();
}
catch (Microsoft.Graph.ServiceException e)
{
Console.WriteLine(e.Error);
}
the following error should be printed:
Code: ErrorAccessDenied
Message: Access is denied. Check credentials and try again.

GooglePlaces API "Response That We Couldn't Understand" Error

Using the standard autocomplete code with a searchbar:
placesClient.autocompleteQuery(searchBar.textField.text!, bounds: nil, filter: filter, callback: {(results, error) -> Void in
if let error = error {
print("Autocomplete error \(error)")
return
}
if let results = results {
for result in results {
print("Result \(result.attributedFullText) with placeID \(result.placeID)")
self.predictions.append(result)
}
}
self.placesTableView.reloadData()
})
Has been working for months and tonight it started reporting this error:
Autocomplete error Error Domain=com.google.places.ErrorDomain Code=-2 "The Places API server returned a response that we couldn't understand. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/support)."
UserInfo={NSLocalizedFailureReason=The Places API server returned a response that we couldn't understand. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/support)., NSUnderlyingError=0x600000444380 {Error Domain=com.google.places.server.ErrorDomain Code=-1 "(null)" UserInfo={NSUnderlyingError=0x600000444350 {Error Domain=com.google.HTTPStatus Code=404 "Not Found" UserInfo={NSLocalizedDescription=Not Found}}}}}
Anyone else experiencing this?
Looks like the service is back up. I raised a ticket with Google.
They identified the issue and are resolving it. Mentioned it could take a few hours.
See below:
https://issuetracker.google.com/issues/64280749
https://issuetracker.google.com/issues/64994023
This issue has been filed with Google, Google has identified the bug, and they are currently working on a fix. Issue tracking: https://issuetracker.google.com/issues/64280749
See: why loading places in iOS using google places api causes lookup place id query error?
thank-you: #trishcode

Google Places API Autocomplete not working bad request

I'm trying to use Google places API to get autocomplete.
I've checked everything:
API keys are activated (disabled every restriction)
I'm calling GMSServices.provideAPIKey and GMSPlacesClient.provideAPIKey
Initializing the object placesClient = GMSPlacesClient.shared()
The call I'm making is:
let filter = GMSAutocompleteFilter()
filter.type = .establishment
placesClient?.autocompleteQuery(textField.text!, bounds: nil, filter: filter) { (predictionList, error) in
if let error = error {
print("Pick Place error: \(error.localizedDescription)")
return
}
if let list = predictionList{
self.resultList = list
}
}
The error I'm getting is:
Printing description of error: Error
Domain=com.google.places.ErrorDomain Code=-3 "An internal error
occurred in the Places API library. If you believe this error
represents a bug, please file a report using the instructions on our
community and support page
(https://developers.google.com/places/support)."
UserInfo={NSLocalizedFailureReason=An internal error occurred in the
Places API library. If you believe this error represents a bug, please
file a report using the instructions on our community and support page
(https://developers.google.com/places/support).,
NSUnderlyingError=0x608000445370 {Error
Domain=com.google.places.server.ErrorDomain Code=-1 "(null)"
UserInfo={NSUnderlyingError=0x60800024f030 {Error
Domain=com.google.GTLRErrorObjectDomain Code=400 "(Bad Request)"
UserInfo={error=Bad Request, GTLRStructuredError=GMSx_GTLRErrorObject
0x60800024f9f0: {message:"Bad Request" errors:[1] code:400},
NSLocalizedFailureReason=(Bad Request)}}}}}
Has anyone else seen this problem in Xcode 8 iOS 10? Thanks
EDIT: Now it seems that some requests are working... Maybe the server is having problems?

Resources