MCPcopy
hub / github.com/fastify/fastify / anonymous0

Function anonymous0

lib/error-serializer.js:44–128  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

42
43 // #
44 function anonymous0 (input) {
45 const obj = (input && typeof input.toJSON === 'function')
46 ? input.toJSON()
47 : input
48
49 if (obj === null) return JSON_STR_EMPTY_OBJECT
50 let json = ''
51
52 json += JSON_STR_BEGIN_OBJECT
53let addComma_0 = false
54
55 const value_statusCode_1 = obj["statusCode"]
56 if (value_statusCode_1 !== undefined) {
57 !addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
58 json += "\"statusCode\":"
59 json += asNumber(value_statusCode_1)
60 }
61
62 const value_code_2 = obj["code"]
63 if (value_code_2 !== undefined) {
64 !addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
65 json += "\"code\":"
66
67 if (typeof value_code_2 !== 'string') {
68 if (value_code_2 === null) {
69 json += JSON_STR_EMPTY_STRING
70 } else if (value_code_2 instanceof Date) {
71 json += JSON_STR_QUOTE + value_code_2.toISOString() + JSON_STR_QUOTE
72 } else if (value_code_2 instanceof RegExp) {
73 json += asString(value_code_2.source)
74 } else {
75 json += asString(value_code_2.toString())
76 }
77 } else {
78 json += asString(value_code_2)
79 }
80
81 }
82
83 const value_error_3 = obj["error"]
84 if (value_error_3 !== undefined) {
85 !addComma_0 && (addComma_0 = true) || (json += JSON_STR_COMMA)
86 json += "\"error\":"
87
88 if (typeof value_error_3 !== 'string') {
89 if (value_error_3 === null) {
90 json += JSON_STR_EMPTY_STRING
91 } else if (value_error_3 instanceof Date) {
92 json += JSON_STR_QUOTE + value_error_3.toISOString() + JSON_STR_QUOTE
93 } else if (value_error_3 instanceof RegExp) {
94 json += asString(value_error_3.source)
95 } else {
96 json += asString(value_error_3.toString())
97 }
98 } else {
99 json += asString(value_error_3)
100 }
101

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…