esctl icon indicating copy to clipboard operation
esctl copied to clipboard

Catch HTTP errors that create stacktrace

Open jeromepin opened this issue 3 years ago • 0 comments

When an HTTP error arises, the cliff formatter cannot format the HTTP response according to the object's class, thus it prints a very-not-helpful stacktrace. It would be nice to find a way to catch it.

Example :

[DEBUG] https://localhost:9200 "GET /_cluster/allocation/explain HTTP/1.1" 429 869
[WARNING] GET https://localhost:9200/_cluster/allocation/explain [status:429 request:0.595s]
[DEBUG] > None
[DEBUG] < {
    "error": {
        "root_cause": [
            {
                "type": "circuit_breaking_exception",
                "reason": "[parent] Data too large, data for [<http_request>] would be [2043081104/1.9gb], which is larger than the limit of [2031828992/1.8gb], real usage: [2043081104/1.9gb], new bytes reserved: [0/0b], usages [request=0/0b, fielddata=46926/45.8kb, in_flight_requests=0/0b, accounting=2935216/2.7mb]",
                "bytes_wanted": 2043081104,
                "bytes_limit": 2031828992,
                "durability": "PERMANENT"
            }
        ],
        "type": "circuit_breaking_exception",
        "reason": "[parent] Data too large, data for [<http_request>] would be [2043081104/1.9gb], which is larger than the limit of [2031828992/1.8gb], real usage: [2043081104/1.9gb], new bytes reserved: [0/0b], usages [request=0/0b, fielddata=46926/45.8kb, in_flight_requests=0/0b, accounting=2935216/2.7mb]",
        "bytes_wanted": 2043081104,
        "bytes_limit": 2031828992,
        "durability": "PERMANENT"
    },
    "status": 429
}
[ERROR] cannot unpack non-iterable NoneType object
Traceback (most recent call last):
    File "/Users/jeromepin/.asdf/installs/python/3.7.9/lib/python3.7/site-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
    File "/Users/jeromepin/.asdf/installs/python/3.7.9/lib/python3.7/site-packages/cliff/display.py", line 117, in run
    column_names, data = self.take_action(parsed_args)
TypeError: cannot unpack non-iterable NoneType object
[DEBUG] got an error: cannot unpack non-iterable NoneType object

jeromepin avatar Apr 21 '21 09:04 jeromepin