MCPcopy Create free account
hub / github.com/chain/Core / Format

Method Format

net/http/httperror/httperror.go:45–67  ·  view source on GitHub ↗

Format builds an error Response body describing err by consulting the f.Errors lookup table. If no entry is found, it returns f.Default.

(err error)

Source from the content-addressed store, hash-verified

43// Format builds an error Response body describing err by consulting
44// the f.Errors lookup table. If no entry is found, it returns f.Default.
45func (f Formatter) Format(err error) (body Response) {
46 root := errors.Root(err)
47 // Some types cannot be used as map keys, for example slices.
48 // If an error's underlying type is one of these, don't panic.
49 // Just treat it like any other missing entry.
50 defer func() {
51 if err := recover(); err != nil {
52 body = Response{f.Default, "", nil, true}
53 }
54 }()
55 info, ok := f.Errors[root]
56 if !ok {
57 info = f.Default
58 }
59
60 body = Response{
61 Info: info,
62 Detail: errors.Detail(err),
63 Data: errors.Data(err),
64 Temporary: f.IsTemporary(info, err),
65 }
66 return body
67}
68
69// Write writes a json encoded Response to the ResponseWriter.
70// It uses the status code associated with the error.

Callers 15

WriteMethod · 0.95
LogMethod · 0.95
formatPrefixFunction · 0.80
batchRecoverFunction · 0.80
mockhsmSignTemplatesMethod · 0.80
buildSingleMethod · 0.80
addAllowedMemberMethod · 0.80
PrintStatusFunction · 0.80
migrateAccessTokensFunction · 0.80
PrintkvFunction · 0.80
mustBuildFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestInfoFunction · 0.64