From fd0b90d21f9ab4b5dd398e9526b570bfea86e370 Mon Sep 17 00:00:00 2001 From: repon Date: Wed, 22 Apr 2026 12:12:18 +0200 Subject: [PATCH] acme: include Problem in OrderError.Error An ACME Order object can contain an error field when it is invalid. Previously, OrderError.Error() ignored this field, making it difficult to diagnose why an order failed. This change includes the problem details if available. Change-Id: I461fd02ef02251a2ba1e8cea39b5df8070938117 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/772880 Reviewed-by: Roland Shoemaker Reviewed-by: Sean Liao LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com Reviewed-by: Daniel McCarney --- acme/types.go | 6 +++++- acme/types_test.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/acme/types.go b/acme/types.go index 322640c..65d69b2 100644 --- a/acme/types.go +++ b/acme/types.go @@ -167,7 +167,11 @@ type OrderError struct { } func (oe *OrderError) Error() string { - return fmt.Sprintf("acme: order %s status: %s", oe.OrderURL, oe.Status) + str := fmt.Sprintf("acme: order %s status: %s", oe.OrderURL, oe.Status) + if oe.Problem != nil { + str += fmt.Sprintf("; problem: %s", oe.Problem) + } + return str } // RateLimit reports whether err represents a rate limit error and diff --git a/acme/types_test.go b/acme/types_test.go index 59ce7e7..2a59f6f 100644 --- a/acme/types_test.go +++ b/acme/types_test.go @@ -217,3 +217,19 @@ func TestErrorStringerWithSubproblems(t *testing.T) { t.Errorf("Unexpected error string: wanted %q, got %q", expectedStr, err.Error()) } } + +func TestOrderErrorProblem(t *testing.T) { + oe := &OrderError{ + OrderURL: "url", + Status: "invalid", + Problem: &Error{ + StatusCode: 400, + ProblemType: "type", + Detail: "detail", + }, + } + want := "acme: order url status: invalid; problem: 400 type: detail" + if got := oe.Error(); got != want { + t.Errorf("oe.Error() = %q, want %q", got, want) + } +}