From b9a1ab625b20faa3193f34a0f768dbfaa4de506d Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 31 Oct 2024 23:02:29 +0300 Subject: [PATCH 1/2] Improve APIError message --- pachca.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pachca.go b/pachca.go index 00e744a..e25967f 100644 --- a/pachca.go +++ b/pachca.go @@ -387,7 +387,10 @@ func (d *Date) UnmarshalJSON(b []byte) error { // Error returns error text func (e APIError) Error() string { - return fmt.Sprintf("(%s) %s [%s:%s]", e.Code, e.Message, e.Key, e.Value) + return fmt.Sprintf( + "(%s) %s [%s:%s]", + e.Code, e.Message, e.Key, strutil.Q(e.Value, "-"), + ) } // ////////////////////////////////////////////////////////////////////////////////// // From b167062e37d74c0b206cb4a01516749e50bb2b30 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Thu, 31 Oct 2024 23:04:16 +0300 Subject: [PATCH 2/2] Fix tests --- pachca_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pachca_test.go b/pachca_test.go index 51bc462..72e2b9c 100644 --- a/pachca_test.go +++ b/pachca_test.go @@ -558,5 +558,5 @@ func (s *PachcaSuite) TestAPIErrorToString(c *C) { StatusCode: 400, } - c.Assert(err.Error(), Equals, "(unhandled) Ошибка выполнения запроса [system:]") + c.Assert(err.Error(), Equals, "(unhandled) Ошибка выполнения запроса [system:-]") }