From de7b04006965e7383b129f952a169adafbdfef02 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 17 Jul 2024 19:00:30 +0200 Subject: [PATCH] Fix --log-format parsing (#252) I broke it at https://github.com/stellar/soroban-rpc/pull/228 It turns out that `github.com/stellar/go/support/errors.Wrapf` returns nil if the error is nil (which is different to how `errors.Errorf` behaves). I have looked at both https://github.com/stellar/soroban-rpc/pull/228 and https://github.com/stellar/soroban-rpc/pull/224 and this is the only instance in which we replaced `Wrapf` by `Errorf` where we don't first check the error for `nil`. --- cmd/soroban-rpc/internal/config/options.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-rpc/internal/config/options.go b/cmd/soroban-rpc/internal/config/options.go index 9d14084a..9fb80996 100644 --- a/cmd/soroban-rpc/internal/config/options.go +++ b/cmd/soroban-rpc/internal/config/options.go @@ -121,11 +121,9 @@ func (cfg *Config) options() Options { case nil: return nil case string: - return fmt.Errorf( - "could not parse %s: %w", - option.Name, - cfg.LogFormat.UnmarshalText([]byte(v)), - ) + if err := cfg.LogFormat.UnmarshalText([]byte(v)); err != nil { + return fmt.Errorf("could not parse %s: %w", option.Name, err) + } case LogFormat: cfg.LogFormat = v case *LogFormat: