I need to determine no internet exception when connecting to server without network. But on iOS I get IOException(On Android exception is ConnectException).
The message of exception contains this error message:
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x10bc06330 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=http://..., NSErrorFailingURLKey=http://..., _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}`
I can parse this message and check if it contains Code=-1009. But, is there a more elegant way to check NSError from JavaLangException?