From 4e8f415d35c127ccc8d1516a7694d4d95e0cd22c Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 17 Jul 2024 17:49:12 +0200 Subject: [PATCH] Fix --log-format parsing 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..e9b482f9 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", err) + } case LogFormat: cfg.LogFormat = v case *LogFormat: