Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Prettify nested error messages #326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m1k1o
Copy link

@m1k1o m1k1o commented Apr 14, 2023

When using custom hooks and calling multiple decode functions, error output is not really human readable:

19 error(s) decoding:

* '' has invalid keys: log
* cannot parse 'transport.disable_compression' as bool: strconv.ParseBool: parsing "<bool>": invalid syntax
* cannot parse 'transport.disable_keep_alives' as bool: strconv.ParseBool: parsing "<bool>": invalid syntax
* cannot parse 'transport.force_attempt_http2' as bool: strconv.ParseBool: parsing "<bool>": invalid syntax
* cannot parse 'transport.max_conns_per_host' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.max_idle_conns' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.max_idle_conns_per_host' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.max_response_header_bytes' as int: strconv.ParseInt: parsing "<int64>": invalid syntax
* cannot parse 'transport.read_buffer_size' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.write_buffer_size' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* error decoding 'proxy.middlewares[0]': failed to unmarshal provider cache: 1 error(s) decoding:

* error decoding 'provider': failed to unmarshal provider memory: 1 error(s) decoding:

* '' has invalid keys: ttl
* error decoding 'proxy.providers[1]': failed to unmarshal provider http: 1 error(s) decoding:

* '' has invalid keys: proxy
* error decoding 'proxy.providers[2]': failed to unmarshal provider hls: 1 error(s) decoding:

* error decoding 'proxy.middlewares[0]': failed to unmarshal provider cache: 1 error(s) decoding:

* error decoding 'provider': failed to unmarshal provider memory: 1 error(s) decoding:

* '' has invalid keys: ttl
* error decoding 'transport.dial_keep_alive': time: invalid duration "<time.Duration>"
* error decoding 'transport.dial_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.expect_continue_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.idle_conn_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.response_header_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.tls_handshake_timeout': time: invalid duration "<time.Duration>"

Changing to more readable format:

command execution finished with error: failed to unmarshal service config: 19 error(s) decoding:
* cannot parse 'transport.disable_compression' as bool: strconv.ParseBool: parsing "<bool>": invalid syntax
* cannot parse 'transport.disable_keep_alives' as bool: strconv.ParseBool: parsing "<bool>": invalid syntax
* cannot parse 'transport.force_attempt_http2' as bool: strconv.ParseBool: parsing "<bool>": invalid syntax
* cannot parse 'transport.max_conns_per_host' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.max_idle_conns' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.max_idle_conns_per_host' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.max_response_header_bytes' as int: strconv.ParseInt: parsing "<int64>": invalid syntax
* cannot parse 'transport.read_buffer_size' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* cannot parse 'transport.write_buffer_size' as int: strconv.ParseInt: parsing "<int>": invalid syntax
* error decoding 'proxy.middlewares[0]': failed to unmarshal provider cache: 1 error(s) decoding:
  * error decoding 'provider': failed to unmarshal provider memory: 1 error(s) decoding:
    * invalid keys: ttl
* error decoding 'proxy.providers[1]': failed to unmarshal provider http: 1 error(s) decoding:
  * invalid keys: proxy
* error decoding 'proxy.providers[2]': failed to unmarshal provider hls: 1 error(s) decoding:
  * error decoding 'proxy.middlewares[0]': failed to unmarshal provider cache: 1 error(s) decoding:
    * error decoding 'provider': failed to unmarshal provider memory: 1 error(s) decoding:
      * invalid keys: ttl
* error decoding 'transport.dial_keep_alive': time: invalid duration "<time.Duration>"
* error decoding 'transport.dial_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.expect_continue_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.idle_conn_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.response_header_timeout': time: invalid duration "<time.Duration>"
* error decoding 'transport.tls_handshake_timeout': time: invalid duration "<time.Duration>"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant