Skip to content

Commit 46146b9

Browse files
committed
chore: PR fixups, renames and comments
1 parent 8d594a7 commit 46146b9

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

coderd/dynamicparameters/error.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ func TagValidationError(diags hcl.Diagnostics) *DiagnosticError {
2727
}
2828

2929
type DiagnosticError struct {
30-
Message string
31-
Diagnostics hcl.Diagnostics
30+
// Message is the human-readable message that will be returned to the user.
31+
Message string
32+
// Diagnostics are top level diagnostics that will be returned as "Detail" in the response.
33+
Diagnostics hcl.Diagnostics
34+
// KeyedDiagnostics translate to Validation errors in the response. A key could
35+
// be a parameter name, or a tag name. This allows diagnostics to be more closely
36+
// associated with a specific index/parameter/tag.
3237
KeyedDiagnostics map[string]hcl.Diagnostics
3338
}
3439

coderd/httpapi/httperror/responserror.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"github.com/coder/coder/v2/codersdk"
77
)
88

9-
type CoderSDKError interface {
9+
type Responder interface {
1010
Response() (int, codersdk.Response)
1111
}
1212

13-
func IsCoderSDKError(err error) (CoderSDKError, bool) {
14-
var responseErr CoderSDKError
13+
func IsResponder(err error) (Responder, bool) {
14+
var responseErr Responder
1515
if errors.As(err, &responseErr) {
1616
return responseErr, true
1717
}

coderd/httpapi/httperror/wsbuild.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func WriteWorkspaceBuildError(ctx context.Context, rw http.ResponseWriter, err error) {
12-
if responseErr, ok := IsCoderSDKError(err); ok {
12+
if responseErr, ok := IsResponder(err); ok {
1313
code, resp := responseErr.Response()
1414

1515
httpapi.Write(ctx, rw, code, resp)

coderd/wsbuilder/wsbuilder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ func TestWsbuildError(t *testing.T) {
10101010
Message: msg,
10111011
}
10121012

1013-
respErr, ok := httperror.IsCoderSDKError(buildErr)
1013+
respErr, ok := httperror.IsResponder(buildErr)
10141014
require.True(t, ok, "should be a Coder SDK error")
10151015

10161016
code, resp := respErr.Response()

0 commit comments

Comments
 (0)