Keep `DioException.toString` clean !!!
Request Statement
To be honest, the new added detail message about the error reason, is useless for developer. Such as:
This exception was thrown because the response has a status code of 504 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 504 has the following meaning: "Server error - the server failed to fulfil an apparently valid request"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.
In most cases, developer will log error to console or file, these messages are useless and annoying. Which developer doesn't know the http code meaning? If one kind of error keeps raising, the log will be filled with these useless texts.
Solution Brainstorm
Ensure toString only print "necessary" info, and print extra helpful info in another method like toDetailString.
So if want to show user the error detail, we could just call DioException.toDetailString. If we want to print or logging, normal toString is enough.
To ignore these useless text, I have to dig into each logging process, each error print process to "Remove" these message, or even ignore entire DioException.
@ueman Do you want to evaluate the request? I do think that is fair enough, and if we need to change this, we might also consider to support https://github.com/cfug/dio/issues/1949.
It was introduced since we had a lot of people in the past creating issues for exceptions being thrown due to bad HTTP status codes.
So in contrast to what the issue says, a lot of people do indeed not know HTTP status codes.
I probably wouldn't introduce something like the suggestion but rather make it more verbose in debug mode vs release mode.
That being said, I would like to further understand what the issue with being verbose is.
In most cases, developer will log error to console or file, these messages are useless and annoying. Which developer doesn't know the http code meaning?
I realise that this is a rethorical question, but people who just start out don't know, and for those these kinds of messages are super helpful. Not everyone knows as much as you or I.
@ueman maybe we can add a configuration, such as static field Dio.loggingMode, then decide the logging format according to this field value. by deafult, it can be set to detail logging
I've filed 2 PRs to find out if there is a better answer for the issue. Please vote or add comments if you'd like to.
- https://github.com/cfug/dio/pull/2296
- https://github.com/cfug/dio/pull/2297