More user-friendly curl-like output in case of error
See original GitHub issueI really love HTTPie for the cases when everything works fine, but if HTTPie can’t establish connection by some reason then I always have to switch back to curl to perform troubleshooting
Example:
http: error: ConnectionError: HTTPSConnectionPool(host='myhost', port=32075): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x6fffed76630>: Failed to establish a new connection: [Errno 13] Permission denied')) while doing OPTIONS request to URL: https://myhost:32075/
Whole error message displayed in one line with a lot of unclear diagnostics + Python’s stacktrace. Please make it more user-friendly/clear + modify formatting to improve readability Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Gracefully handle DNS failures · Issue #1248 · httpie ... - GitHub
More user-friendly curl-like output in case of error #815. Closed. @isidentical isidentical added this to the HTTPie 3.0 milestone on Dec 29 ...
Read more >HTTPie: A cURL-like tool for humans | Hacker News
This is a nice curl and wget replacement that handles a bunch of modern use-cases without a lot of hard-to-remember command-line flags.
Read more >Ubuntu Manpage: httpie - CLI, cURL-like tool for humans
HTTPie is a CLI HTTP utility built out of frustration with existing tools. The goal is to make CLI interaction with HTTP-based services...
Read more >Use output of a CURL and fail if the output contains ERROR
Sorry I have missed out to say, I want to send output of CURL statement to a keyword(eg: $quality_gatesstatus) but how to send...
Read more >The Art Of Scripting HTTP Requests Using Curl
It will prepend the time to each trace output line: ... The most common case is probably to just use one, but you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes! @jakubroztocil that makes sense to me. Thank you!
@juped @rch-liu @ebonnecab awesome!
I would start by manually triggering & identifying as many types of errors as possible (by connecting to non-existing servers, passing weird arguments, making requests while offline, …, be creative!).
For each error type for which it makes sense (for example, arguments errors are already handled by
argparse
), I‘d write a function that returns a useful string representation with enough context for the user. with these, I would create a mapping between error types and the corresponding function.Then, I‘d update the current catch-all handling to first try to get a custom representation for the given error from the mapping, and only if that fails, I‘d print out the exception like we do now.
https://github.com/jakubroztocil/httpie/blob/7ee519ef46ed0a4280f431d0c14745ed8244621f/httpie/core.py#L96-L109
The style and formatting of the errors should be consistent (between the new as well as the already existing errors).
Each of the supported error types needs a test case:
https://github.com/jakubroztocil/httpie/blob/master/tests/test_errors.py
If anything, ask away!