From c4b2fed5835c37eb8818a78fd3ae2e7b26e85043 Mon Sep 17 00:00:00 2001 From: Kubo Ryosuke Date: Thu, 3 Dec 2020 01:10:13 +0900 Subject: [PATCH] fix error handling --- string.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/string.go b/string.go index af53b49..c3bc30d 100644 --- a/string.go +++ b/string.go @@ -161,9 +161,7 @@ func (m *stringifier) stringifyArray(t reflect.Type, v reflect.Value, config fie m2.buf.WriteString(sep) } - var err error - err = m2.stringify(t.Elem(), v.Index(i), config, depth+1) - if err != nil { + if err := m2.stringify(t.Elem(), v.Index(i), config, depth+1); err != nil { return err } } @@ -197,7 +195,9 @@ func (m *stringifier) stringifySlice(t reflect.Type, v reflect.Value, config fie m2.buf.WriteString(sep) } - m2.stringify(t.Elem(), v.Index(i), config, depth+1) + if err := m2.stringify(t.Elem(), v.Index(i), config, depth+1); err != nil { + return err + } } if config.str { m.buf.WriteString(util.EscapeUnprintables(m2.buf.String()))