MCPcopy Index your code
hub / github.com/coder/coder / extractErrorString

Function extractErrorString

coderd/x/chatd/chatprompt/chatprompt.go:583–597  ·  view source on GitHub ↗

extractErrorString pulls the "error" field from a JSON object if present, returning it as a string. Returns "" if the field is missing or the input is not an object.

(raw json.RawMessage)

Source from the content-addressed store, hash-verified

581// present, returning it as a string. Returns "" if the field is
582// missing or the input is not an object.
583func extractErrorString(raw json.RawMessage) string {
584 var fields map[string]json.RawMessage
585 if err := json.Unmarshal(raw, &fields); err != nil {
586 return ""
587 }
588 errField, ok := fields["error"]
589 if !ok {
590 return ""
591 }
592 var s string
593 if err := json.Unmarshal(errField, &s); err != nil {
594 return ""
595 }
596 return strings.TrimSpace(s)
597}
598
599func normalizeAssistantToolCallInputs(
600 parts []fantasy.MessagePart,

Callers 1

Calls 1

UnmarshalMethod · 0.45

Tested by

no test coverage detected