UNPKG

3.55 kBJavaScriptView Raw
1// This file is autogenerated by build/build-error-serializer.js, do not edit
2/* istanbul ignore file */
3
4 'use strict'
5
6 const Serializer = require('fast-json-stringify/lib/serializer')
7 const serializerState = {"mode":"standalone"}
8 const serializer = Serializer.restoreFromState(serializerState)
9
10 const validator = null
11
12
13 module.exports = function anonymous(validator,serializer
14) {
15
16 const JSON_STR_BEGIN_OBJECT = '{'
17 const JSON_STR_END_OBJECT = '}'
18 const JSON_STR_BEGIN_ARRAY = '['
19 const JSON_STR_END_ARRAY = ']'
20 const JSON_STR_COMMA = ','
21 const JSON_STR_COLONS = ':'
22 const JSON_STR_QUOTE = '"'
23 const JSON_STR_EMPTY_OBJECT = JSON_STR_BEGIN_OBJECT + JSON_STR_END_OBJECT
24 const JSON_STR_EMPTY_ARRAY = JSON_STR_BEGIN_ARRAY + JSON_STR_END_ARRAY
25 const JSON_STR_EMPTY_STRING = JSON_STR_QUOTE + JSON_STR_QUOTE
26 const JSON_STR_NULL = 'null'
27
28
29
30 // #
31 function anonymous0 (input) {
32 const obj = (input && typeof input.toJSON === 'function')
33 ? input.toJSON()
34 : input
35
36 if (obj === null) return JSON_STR_EMPTY_OBJECT
37
38 let value
39let json = JSON_STR_BEGIN_OBJECT
40let addComma = false
41
42 value = obj["statusCode"]
43 if (value !== undefined) {
44 !addComma && (addComma = true) || (json += JSON_STR_COMMA)
45 json += "\"statusCode\":"
46 json += serializer.asNumber(value)
47 }
48
49 value = obj["code"]
50 if (value !== undefined) {
51 !addComma && (addComma = true) || (json += JSON_STR_COMMA)
52 json += "\"code\":"
53
54 if (typeof value !== 'string') {
55 if (value === null) {
56 json += JSON_STR_EMPTY_STRING
57 } else if (value instanceof Date) {
58 json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE
59 } else if (value instanceof RegExp) {
60 json += serializer.asString(value.source)
61 } else {
62 json += serializer.asString(value.toString())
63 }
64 } else {
65 json += serializer.asString(value)
66 }
67
68 }
69
70 value = obj["error"]
71 if (value !== undefined) {
72 !addComma && (addComma = true) || (json += JSON_STR_COMMA)
73 json += "\"error\":"
74
75 if (typeof value !== 'string') {
76 if (value === null) {
77 json += JSON_STR_EMPTY_STRING
78 } else if (value instanceof Date) {
79 json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE
80 } else if (value instanceof RegExp) {
81 json += serializer.asString(value.source)
82 } else {
83 json += serializer.asString(value.toString())
84 }
85 } else {
86 json += serializer.asString(value)
87 }
88
89 }
90
91 value = obj["message"]
92 if (value !== undefined) {
93 !addComma && (addComma = true) || (json += JSON_STR_COMMA)
94 json += "\"message\":"
95
96 if (typeof value !== 'string') {
97 if (value === null) {
98 json += JSON_STR_EMPTY_STRING
99 } else if (value instanceof Date) {
100 json += JSON_STR_QUOTE + value.toISOString() + JSON_STR_QUOTE
101 } else if (value instanceof RegExp) {
102 json += serializer.asString(value.source)
103 } else {
104 json += serializer.asString(value.toString())
105 }
106 } else {
107 json += serializer.asString(value)
108 }
109
110 }
111
112 return json + JSON_STR_END_OBJECT
113
114 }
115
116 const main = anonymous0
117 return main
118
119}(validator, serializer)