MCPcopy
hub / github.com/ory/hydra / formatErrorMessage

Function formatErrorMessage

internal/httpclient/client.go:674–691  ·  view source on GitHub ↗

format error message using title and detail when model implements rfc7807

(status string, v interface{})

Source from the content-addressed store, hash-verified

672
673// format error message using title and detail when model implements rfc7807
674func formatErrorMessage(status string, v interface{}) string {
675 str := ""
676 metaValue := reflect.ValueOf(v).Elem()
677
678 if metaValue.Kind() == reflect.Struct {
679 field := metaValue.FieldByName("Title")
680 if field != (reflect.Value{}) {
681 str = fmt.Sprintf("%s", field.Interface())
682 }
683
684 field = metaValue.FieldByName("Detail")
685 if field != (reflect.Value{}) {
686 str = fmt.Sprintf("%s (%s)", str, field.Interface())
687 }
688 }
689
690 return strings.TrimSpace(fmt.Sprintf("%s %s", status, str))
691}

Calls 1

InterfaceMethod · 0.65

Tested by

no test coverage detected