使用的OkHttp框架做网络请求,但是在onFailure的方法中一句打印失败信息的代码报错了
错误的信息
报错的地方
求指教
高洛峰2017-04-17 17:55:15
e.getMessage() is null, change it to:
e.toString()
In fact, e.getMessage() is of String type, so there is no need to toString() again.
伊谢尔伦2017-04-17 17:55:15
This is a very common Java null pointer exception. It has nothing to do with okhttp. Not all exceptions have messages, so getMessage() cannot guarantee that it is not null, so don’t use it directly.
PHP中文网2017-04-17 17:55:15
Print e.printStackTrace() directly in the onFailure callback function to determine where the IO exception occurred based on the log, and then you can follow the clues to find the problem
ringa_lee2017-04-17 17:55:15
Null pointer exception should not have much to do with okhttp. It may be that there is something wrong with your line of code. Please change the way of writing or thinking.