httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.78k stars 3.68k forks source link

Vague error when unable to find file #256

Closed chrisfosterelli closed 10 years ago

chrisfosterelli commented 10 years ago

Hey! Awesome app, thanks for all the hard work! I noticed that this error could possibly use some clarification:

➜  test git:(master) http POST http://localhost:8000/email example=@./doesntexist.json

http: error: AttributeError: 'ParseError' object has no attribute 'message'
➜  test git:(master) 

The error is that doesntexist.json does not exist, but it can be confusing if you mistype and don't realize it. This also seems to occur when using :@=. Since one of the goals of the project is the following:

to make CLI interaction with web services as human-friendly as possible

Could this error be improved?

jkbrzt commented 10 years ago

Thanks for the report, Chris. I've tried to run that command but HTTPie is giving me a bit nicer, more specific error message:

$ http POST http://localhost:8000/email example=@./doesntexist.json
[…]
http: error: "example=@./doesntexist.json": [Errno 2] No such file or directory: './doesntexist.json'

So I guess it's another issue. Would you please run the following and post the output here as a comment?

$ http --debug POST http://localhost:8000/email example=@./doesntexist.json
chrisfosterelli commented 10 years ago

@jakubroztocil Sure, here you go:

➜  ~  http --debug POST http://localhost:8000/email example=@./doesntexist.json
HTTPie 0.8.0
HTTPie data: /home/stealth/.httpie
Requests 2.2.1
Pygments 1.6
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] linux
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/httpie/input.py", line 609, in parse_items
    with open(os.path.expanduser(value), 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: './doesntexist.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/http", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.4/dist-packages/httpie/core.py", line 84, in main
    args = parser.parse_args(args=args, env=env)
  File "/usr/local/lib/python3.4/dist-packages/httpie/input.py", line 135, in parse_args
    self._parse_items()
  File "/usr/local/lib/python3.4/dist-packages/httpie/input.py", line 325, in _parse_items
    params=self.args.params)
  File "/usr/local/lib/python3.4/dist-packages/httpie/input.py", line 612, in parse_items
    raise ParseError('"%s": %s' % (item.orig, e))
httpie.input.ParseError: "example=@./doesntexist.json": [Errno 2] No such file or directory: './doesntexist.json'
➜  ~  
jkbrzt commented 10 years ago

Thanks. This is actually already fixed in master.