question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More user-friendly curl-like output in case of error

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ebonnecabcommented, Jun 9, 2020

Yes! @jakubroztocil that makes sense to me. Thank you!

1reaction
jakubroztocilcommented, Jun 9, 2020

@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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found