@carecard/common-util 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,187 @@
1
+
2
+ <!doctype html>
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <title>Code coverage report for utilityFunctions.ts</title>
7
+ <meta charset="utf-8" />
8
+ <link rel="stylesheet" href="prettify.css" />
9
+ <link rel="stylesheet" href="base.css" />
10
+ <link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
11
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
12
+ <style type='text/css'>
13
+ .coverage-summary .sorter {
14
+ background-image: url(sort-arrow-sprite.png);
15
+ }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <div class='wrapper'>
21
+ <div class='pad1'>
22
+ <h1><a href="index.html">All files</a> utilityFunctions.ts</h1>
23
+ <div class='clearfix'>
24
+
25
+ <div class='fl pad1y space-right2'>
26
+ <span class="strong">88.88% </span>
27
+ <span class="quiet">Statements</span>
28
+ <span class='fraction'>8/9</span>
29
+ </div>
30
+
31
+
32
+ <div class='fl pad1y space-right2'>
33
+ <span class="strong">50% </span>
34
+ <span class="quiet">Branches</span>
35
+ <span class='fraction'>2/4</span>
36
+ </div>
37
+
38
+
39
+ <div class='fl pad1y space-right2'>
40
+ <span class="strong">100% </span>
41
+ <span class="quiet">Functions</span>
42
+ <span class='fraction'>1/1</span>
43
+ </div>
44
+
45
+
46
+ <div class='fl pad1y space-right2'>
47
+ <span class="strong">88.88% </span>
48
+ <span class="quiet">Lines</span>
49
+ <span class='fraction'>8/9</span>
50
+ </div>
51
+
52
+
53
+ </div>
54
+ <p class="quiet">
55
+ Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
56
+ </p>
57
+ <template id="filterTemplate">
58
+ <div class="quiet">
59
+ Filter:
60
+ <input type="search" id="fileSearch">
61
+ </div>
62
+ </template>
63
+ </div>
64
+ <div class='status-line high'></div>
65
+ <pre><table class="coverage">
66
+ <tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
67
+ <a name='L2'></a><a href='#L2'>2</a>
68
+ <a name='L3'></a><a href='#L3'>3</a>
69
+ <a name='L4'></a><a href='#L4'>4</a>
70
+ <a name='L5'></a><a href='#L5'>5</a>
71
+ <a name='L6'></a><a href='#L6'>6</a>
72
+ <a name='L7'></a><a href='#L7'>7</a>
73
+ <a name='L8'></a><a href='#L8'>8</a>
74
+ <a name='L9'></a><a href='#L9'>9</a>
75
+ <a name='L10'></a><a href='#L10'>10</a>
76
+ <a name='L11'></a><a href='#L11'>11</a>
77
+ <a name='L12'></a><a href='#L12'>12</a>
78
+ <a name='L13'></a><a href='#L13'>13</a>
79
+ <a name='L14'></a><a href='#L14'>14</a>
80
+ <a name='L15'></a><a href='#L15'>15</a>
81
+ <a name='L16'></a><a href='#L16'>16</a>
82
+ <a name='L17'></a><a href='#L17'>17</a>
83
+ <a name='L18'></a><a href='#L18'>18</a>
84
+ <a name='L19'></a><a href='#L19'>19</a>
85
+ <a name='L20'></a><a href='#L20'>20</a>
86
+ <a name='L21'></a><a href='#L21'>21</a>
87
+ <a name='L22'></a><a href='#L22'>22</a>
88
+ <a name='L23'></a><a href='#L23'>23</a>
89
+ <a name='L24'></a><a href='#L24'>24</a>
90
+ <a name='L25'></a><a href='#L25'>25</a>
91
+ <a name='L26'></a><a href='#L26'>26</a>
92
+ <a name='L27'></a><a href='#L27'>27</a>
93
+ <a name='L28'></a><a href='#L28'>28</a>
94
+ <a name='L29'></a><a href='#L29'>29</a>
95
+ <a name='L30'></a><a href='#L30'>30</a>
96
+ <a name='L31'></a><a href='#L31'>31</a>
97
+ <a name='L32'></a><a href='#L32'>32</a>
98
+ <a name='L33'></a><a href='#L33'>33</a>
99
+ <a name='L34'></a><a href='#L34'>34</a>
100
+ <a name='L35'></a><a href='#L35'>35</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
101
+ <span class="cline-any cline-neutral">&nbsp;</span>
102
+ <span class="cline-any cline-neutral">&nbsp;</span>
103
+ <span class="cline-any cline-neutral">&nbsp;</span>
104
+ <span class="cline-any cline-neutral">&nbsp;</span>
105
+ <span class="cline-any cline-neutral">&nbsp;</span>
106
+ <span class="cline-any cline-neutral">&nbsp;</span>
107
+ <span class="cline-any cline-neutral">&nbsp;</span>
108
+ <span class="cline-any cline-neutral">&nbsp;</span>
109
+ <span class="cline-any cline-neutral">&nbsp;</span>
110
+ <span class="cline-any cline-yes">3x</span>
111
+ <span class="cline-any cline-neutral">&nbsp;</span>
112
+ <span class="cline-any cline-neutral">&nbsp;</span>
113
+ <span class="cline-any cline-neutral">&nbsp;</span>
114
+ <span class="cline-any cline-neutral">&nbsp;</span>
115
+ <span class="cline-any cline-yes">1x</span>
116
+ <span class="cline-any cline-neutral">&nbsp;</span>
117
+ <span class="cline-any cline-neutral">&nbsp;</span>
118
+ <span class="cline-any cline-yes">1x</span>
119
+ <span class="cline-any cline-no">&nbsp;</span>
120
+ <span class="cline-any cline-neutral">&nbsp;</span>
121
+ <span class="cline-any cline-neutral">&nbsp;</span>
122
+ <span class="cline-any cline-neutral">&nbsp;</span>
123
+ <span class="cline-any cline-yes">1x</span>
124
+ <span class="cline-any cline-yes">2x</span>
125
+ <span class="cline-any cline-neutral">&nbsp;</span>
126
+ <span class="cline-any cline-yes">2x</span>
127
+ <span class="cline-any cline-neutral">&nbsp;</span>
128
+ <span class="cline-any cline-yes">2x</span>
129
+ <span class="cline-any cline-neutral">&nbsp;</span>
130
+ <span class="cline-any cline-neutral">&nbsp;</span>
131
+ <span class="cline-any cline-neutral">&nbsp;</span>
132
+ <span class="cline-any cline-yes">1x</span>
133
+ <span class="cline-any cline-neutral">&nbsp;</span>
134
+ <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">// src/utilityFunctions.ts
135
+ &nbsp;
136
+ /**
137
+ * Create a new object containing only the properties listed in `arrayOfProperties`.
138
+ * Keeps the original behavior: only copies properties whose values are truthy.
139
+ *
140
+ * Example:
141
+ * extractObjectWithProperties({ a: 1, b: 0, c: 'x' }, ['a', 'b', 'c'])
142
+ * -&gt; { a: 1, c: 'x' } // 'b' is omitted because 0 is falsy
143
+ */
144
+ export function extractObjectWithProperties&lt;T extends Record&lt;string, unknown&gt;, K extends keyof T&gt;(
145
+ obj: T | null | undefined,
146
+ arrayOfProperties: ReadonlyArray&lt;K&gt;,
147
+ ): Partial&lt;Pick&lt;T, K&gt;&gt; {
148
+ // Initialize with the correct type to avoid "element implicitly has an 'any' type"
149
+ const returnObj: Partial&lt;Pick&lt;T, K&gt;&gt; = {};
150
+ &nbsp;
151
+ // If obj is null/undefined, return an empty object
152
+ <span class="missing-if-branch" title="if path not taken" >I</span>if (!obj) {
153
+ <span class="cstat-no" title="statement not covered" > return returnObj;</span>
154
+ }
155
+ &nbsp;
156
+ // Iterate using `for...of` to avoid lib/target issues with Array.prototype.find for older configs
157
+ for (const nameOfProperty of arrayOfProperties) {
158
+ const value = obj[nameOfProperty];
159
+ // Preserve original "truthy" filter: only copy if value is truthy
160
+ <span class="missing-if-branch" title="else path not taken" >E</span>if (value) {
161
+ // Assign with proper typing
162
+ returnObj[nameOfProperty] = value as T[K];
163
+ }
164
+ }
165
+ &nbsp;
166
+ return returnObj;
167
+ }
168
+ &nbsp;</pre></td></tr></table></pre>
169
+
170
+ <div class='push'></div><!-- for sticky footer -->
171
+ </div><!-- /wrapper -->
172
+ <div class='footer quiet pad2 space-top1 center small'>
173
+ Code coverage generated by
174
+ <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
175
+ at 2025-12-24T01:50:18.316Z
176
+ </div>
177
+ <script src="prettify.js"></script>
178
+ <script>
179
+ window.onload = function () {
180
+ prettyPrint();
181
+ };
182
+ </script>
183
+ <script src="sorter.js"></script>
184
+ <script src="block-navigation.js"></script>
185
+ </body>
186
+ </html>
187
+
@@ -0,0 +1,194 @@
1
+ TN:
2
+ SF:src/appErrorHandlers.ts
3
+ FN:35,(anonymous_0)
4
+ FN:140,throwAppError
5
+ FN:149,(anonymous_2)
6
+ FN:152,(anonymous_3)
7
+ FN:155,(anonymous_4)
8
+ FN:157,(anonymous_5)
9
+ FN:160,(anonymous_6)
10
+ FN:163,(anonymous_7)
11
+ FN:166,(anonymous_8)
12
+ FN:168,(anonymous_9)
13
+ FN:171,(anonymous_10)
14
+ FN:173,(anonymous_11)
15
+ FN:176,(anonymous_12)
16
+ FN:179,(anonymous_13)
17
+ FN:182,(anonymous_14)
18
+ FN:184,(anonymous_15)
19
+ FN:187,(anonymous_16)
20
+ FN:190,(anonymous_17)
21
+ FN:197,notFound404
22
+ FN:207,appErrorHandler
23
+ FNF:20
24
+ FNH:19
25
+ FNDA:16,(anonymous_0)
26
+ FNDA:16,throwAppError
27
+ FNDA:1,(anonymous_2)
28
+ FNDA:1,(anonymous_3)
29
+ FNDA:1,(anonymous_4)
30
+ FNDA:1,(anonymous_5)
31
+ FNDA:1,(anonymous_6)
32
+ FNDA:1,(anonymous_7)
33
+ FNDA:1,(anonymous_8)
34
+ FNDA:1,(anonymous_9)
35
+ FNDA:1,(anonymous_10)
36
+ FNDA:1,(anonymous_11)
37
+ FNDA:1,(anonymous_12)
38
+ FNDA:1,(anonymous_13)
39
+ FNDA:1,(anonymous_14)
40
+ FNDA:1,(anonymous_15)
41
+ FNDA:1,(anonymous_16)
42
+ FNDA:1,(anonymous_17)
43
+ FNDA:0,notFound404
44
+ FNDA:16,appErrorHandler
45
+ DA:30,3
46
+ DA:36,16
47
+ DA:37,16
48
+ DA:38,16
49
+ DA:39,16
50
+ DA:40,16
51
+ DA:48,3
52
+ DA:140,3
53
+ DA:141,16
54
+ DA:142,16
55
+ DA:149,3
56
+ DA:150,1
57
+ DA:152,3
58
+ DA:153,1
59
+ DA:155,3
60
+ DA:157,3
61
+ DA:158,1
62
+ DA:160,3
63
+ DA:161,1
64
+ DA:163,3
65
+ DA:164,1
66
+ DA:166,3
67
+ DA:168,3
68
+ DA:169,1
69
+ DA:171,3
70
+ DA:173,3
71
+ DA:174,1
72
+ DA:176,3
73
+ DA:177,1
74
+ DA:179,3
75
+ DA:180,1
76
+ DA:182,3
77
+ DA:184,3
78
+ DA:185,1
79
+ DA:187,3
80
+ DA:188,1
81
+ DA:190,3
82
+ DA:191,1
83
+ DA:197,3
84
+ DA:198,0
85
+ DA:207,3
86
+ DA:219,16
87
+ DA:221,16
88
+ DA:222,16
89
+ DA:223,136
90
+ DA:224,136
91
+ DA:225,16
92
+ DA:226,16
93
+ DA:230,16
94
+ DA:232,16
95
+ LF:50
96
+ LH:49
97
+ BRDA:35,0,0,0
98
+ BRDA:39,1,0,16
99
+ BRDA:39,1,1,16
100
+ BRDA:40,2,0,16
101
+ BRDA:40,2,1,16
102
+ BRDA:140,3,0,0
103
+ BRDA:149,4,0,1
104
+ BRDA:152,5,0,1
105
+ BRDA:155,6,0,1
106
+ BRDA:157,7,0,1
107
+ BRDA:160,8,0,1
108
+ BRDA:163,9,0,1
109
+ BRDA:166,10,0,1
110
+ BRDA:168,11,0,1
111
+ BRDA:171,12,0,1
112
+ BRDA:173,13,0,1
113
+ BRDA:176,14,0,1
114
+ BRDA:179,15,0,1
115
+ BRDA:182,16,0,1
116
+ BRDA:184,17,0,1
117
+ BRDA:187,18,0,1
118
+ BRDA:190,19,0,1
119
+ BRDA:224,20,0,16
120
+ BRDA:224,20,1,120
121
+ BRDA:230,21,0,16
122
+ BRDA:230,21,1,0
123
+ BRDA:234,22,0,16
124
+ BRDA:234,22,1,0
125
+ BRDA:234,22,2,0
126
+ BRDA:235,23,0,16
127
+ BRDA:235,23,1,16
128
+ BRDA:235,23,2,0
129
+ BRDA:236,24,0,16
130
+ BRDA:236,24,1,16
131
+ BRF:34
132
+ BRH:28
133
+ end_of_record
134
+ TN:
135
+ SF:src/index.ts
136
+ FNF:0
137
+ FNH:0
138
+ DA:1,3
139
+ DA:2,3
140
+ DA:3,3
141
+ LF:3
142
+ LH:3
143
+ BRF:0
144
+ BRH:0
145
+ end_of_record
146
+ TN:
147
+ SF:src/responseStatus.ts
148
+ FN:29,setOk200
149
+ FN:55,setCreated201
150
+ FN:69,setBadRequest400ClientError
151
+ FNF:3
152
+ FNH:3
153
+ FNDA:1,setOk200
154
+ FNDA:1,setCreated201
155
+ FNDA:1,setBadRequest400ClientError
156
+ DA:29,3
157
+ DA:33,1
158
+ DA:34,1
159
+ DA:36,1
160
+ DA:55,3
161
+ DA:56,1
162
+ DA:57,1
163
+ DA:69,3
164
+ DA:70,1
165
+ DA:71,1
166
+ LF:10
167
+ LH:10
168
+ BRF:0
169
+ BRH:0
170
+ end_of_record
171
+ TN:
172
+ SF:src/utilityFunctions.ts
173
+ FN:11,extractObjectWithProperties
174
+ FNF:1
175
+ FNH:1
176
+ FNDA:1,extractObjectWithProperties
177
+ DA:11,3
178
+ DA:16,1
179
+ DA:19,1
180
+ DA:20,0
181
+ DA:24,1
182
+ DA:25,2
183
+ DA:27,2
184
+ DA:29,2
185
+ DA:33,1
186
+ LF:9
187
+ LH:8
188
+ BRDA:19,0,0,0
189
+ BRDA:19,0,1,1
190
+ BRDA:27,1,0,2
191
+ BRDA:27,1,1,0
192
+ BRF:4
193
+ BRH:2
194
+ end_of_record
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ util: require( './lib/untilityFunctions' ),
3
+ error: require( './lib/appErrorHandlers' ),
4
+ resCode: require( './lib/responseStatus' )
5
+ }
@@ -0,0 +1,264 @@
1
+ 'use strict';
2
+ /**
3
+ * These are application level error handlers. All error responses should be send using these functions.
4
+ * These should be use in app.js file, not in controller files.
5
+ */
6
+ module.exports = {
7
+ notFound404,
8
+ appErrorHandler,
9
+ throwValidationFailureError,
10
+ throwRecordExistError,
11
+ throwWrongCredentialsError,
12
+ throwLoginRequiredError,
13
+ throwRecordNotFoundError,
14
+ throwRecordNotSavedError,
15
+ throwUpdateFailedError,
16
+ throwTransactionFailedError,
17
+ throwUsedTokenError,
18
+ throwBadVisitorTokenError: throwVisitorTokenError,
19
+ throwFileFormatNotSupportedError,
20
+ throwNotAuthorizedError,
21
+ throwBadInputError,
22
+ throwInputNotUuidError,
23
+ throwFileTooLargeError,
24
+ throwInvalidTimeValueError
25
+ }
26
+
27
+
28
+ function notFound404( req, res, next ) {
29
+ res.status( 404 );
30
+ const response = {
31
+ error:
32
+ {
33
+ code: 'NOT_FOUND',
34
+ message: 'Not found',
35
+ details: null
36
+ }
37
+ }
38
+
39
+ res.send( response )
40
+ }
41
+
42
+ function appErrorHandler( err, req, res, next ) {
43
+ const response =
44
+ {
45
+ error:
46
+ {
47
+ code: err.code ?? null,
48
+ message: err.userMessage ?? null,
49
+ details: err.details ?? null
50
+ }
51
+ };
52
+
53
+ switch ( err?.message ) {
54
+
55
+ case "Validation_Failure":
56
+ res.status( 401 );
57
+ res.send( response )
58
+ break;
59
+
60
+ case "Used_Token":
61
+ case "Wrong_Credentials":
62
+ res.status( 401 );
63
+ res.send( response )
64
+ break;
65
+
66
+ case "Bad_Visitor_Token":
67
+ res.status( 401 );
68
+ res.send( response )
69
+ break;
70
+
71
+ case "Record_NotSaved":
72
+ res.status( 400 );
73
+ res.send( response )
74
+ break;
75
+
76
+ case "Record_Exist":
77
+ res.status( 409 );
78
+ res.send( response )
79
+ break;
80
+
81
+ case "Record_NotFound":
82
+ res.status( 404 );
83
+ res.send( response )
84
+ break;
85
+
86
+ case "Update_Failed":
87
+ res.status( 400 );
88
+ res.send( response )
89
+ break;
90
+
91
+ case "Login_Required":
92
+ res.status( 401 );
93
+ res.send( response )
94
+ break;
95
+
96
+ case "Transaction_Failed":
97
+ res.status( 400 );
98
+ res.send( response )
99
+ break;
100
+
101
+ case "File_Format_Not_Supported":
102
+ res.status( 415 );
103
+ res.send( response )
104
+ break;
105
+
106
+ case "Not_Authorized":
107
+ res.status( 401 );
108
+ res.send( response )
109
+ break;
110
+
111
+ case "Bad_Input":
112
+ res.status( 400 );
113
+ res.send( response );
114
+ break;
115
+
116
+ case "Input_Not_Uuid" :
117
+ res.status( 400 );
118
+ res.send( response )
119
+ break;
120
+
121
+ case "File too large":
122
+ res.status( 413 );
123
+ res.send( response )
124
+ break;
125
+
126
+ case "Invalid time value":
127
+ res.status( 403 );
128
+ res.send( response )
129
+ break;
130
+
131
+ default:
132
+ res.status( 500 );
133
+ res.send( response )
134
+ }
135
+ }
136
+
137
+
138
+ function throwValidationFailureError(params={}) {
139
+ const error = new Error( "Validation_Failure" );
140
+ error.code = "VALIDATION_FAILURE";
141
+ error.userMessage = params.userMessage ?? null;
142
+ error.details = params.details ?? null;
143
+ throw error;
144
+ }
145
+
146
+ function throwWrongCredentialsError(params={}) {
147
+ const error = new Error( "Wrong_Credentials" );
148
+ error.code = "WRONG_CREDENTIALS";
149
+ error.userMessage = params.userMessage ?? null;
150
+ error.details = params.details ?? null;
151
+ throw error;
152
+ }
153
+
154
+ function throwRecordExistError(params={}) {
155
+ const error = new Error( "Record_Exist" );
156
+ error.code = "RECORD_EXIST";
157
+ error.userMessage = params.userMessage ?? null;
158
+ error.details = params.details ?? null;
159
+ throw error;
160
+ }
161
+
162
+ function throwRecordNotFoundError(params={}) {
163
+ const error = new Error( "Record_NotFound" );
164
+ error.code = "RECORD_NOT_FOUND";
165
+ error.userMessage = params.userMessage ?? null;
166
+ error.details = params.details ?? null;
167
+ throw error;
168
+ }
169
+
170
+ function throwRecordNotSavedError(params={}) {
171
+ const error = new Error( "Record_NotSaved" );
172
+ error.code = "RECORD_NOT_SAVED";
173
+ error.userMessage = params.userMessage ?? null;
174
+ error.details = params.details ?? null;
175
+ throw error;
176
+ }
177
+
178
+ function throwLoginRequiredError(params={}) {
179
+ const error = new Error( "Login_Required" );
180
+ error.code = "LOGIN_REQUIRED";
181
+ error.userMessage = params.userMessage ?? null;
182
+ error.details = params.details ?? null;
183
+ throw error;
184
+ }
185
+
186
+ function throwUpdateFailedError(params={}) {
187
+ const error = new Error( "Update_Failed" );
188
+ error.code = "UPDATE_FAILED";
189
+ error.userMessage = params.userMessage ?? null;
190
+ error.details = params.details ?? null;
191
+ throw error;
192
+ }
193
+
194
+ function throwTransactionFailedError(params={}) {
195
+ const error = new Error( "Transaction_Failed" );
196
+ error.code = "TRANSACTION_FAILED";
197
+ error.userMessage = params.userMessage ?? null;
198
+ error.details = params.details ?? null;
199
+ throw error;
200
+ }
201
+
202
+ function throwUsedTokenError(params={}) {
203
+ const error = new Error( "Used_Token" );
204
+ error.code = "USED_TOKEN";
205
+ error.userMessage = params.userMessage ?? null;
206
+ error.details = params.details ?? null;
207
+ throw error;
208
+ }
209
+
210
+ function throwVisitorTokenError(params={}) {
211
+ const error = new Error( "Bad_Visitor_Token" );
212
+ error.code = "BAD_VISITOR_TOKEN";
213
+ error.userMessage = params.userMessage ?? null;
214
+ error.details = params.details ?? null;
215
+ throw error;
216
+ }
217
+
218
+ function throwFileFormatNotSupportedError(params={}) {
219
+ const error = new Error( "File_Format_Not_Supported" );
220
+ error.code = "FILE_FORMAT_NOT_SUPPORTED";
221
+ error.userMessage = params.userMessage ?? null;
222
+ error.details = params.details ?? null;
223
+ throw error;
224
+ }
225
+
226
+ function throwNotAuthorizedError(params={}) {
227
+ const error = new Error( "Not_Authorized" );
228
+ error.code = "NOT_AUTHORIZED";
229
+ error.userMessage = params.userMessage ?? null;
230
+ error.details = params.details ?? null;
231
+ throw error;
232
+ }
233
+
234
+ function throwBadInputError(params={}) {
235
+ const error = new Error( "Bad_Input" );
236
+ error.code = "BAD_INPUT";
237
+ error.userMessage = params.userMessage ?? null;
238
+ error.details = params.details ?? null;
239
+ throw error;
240
+ }
241
+
242
+ function throwInputNotUuidError(params={}) {
243
+ const error = new Error( "Input_Not_Uuid" );
244
+ error.code = "INPUT_NOT_UUID";
245
+ error.userMessage = params.userMessage ?? null;
246
+ error.details = params.details ?? null;
247
+ throw error;
248
+ }
249
+
250
+ function throwFileTooLargeError(params={}) {
251
+ const error = new Error( "File too large" );
252
+ error.code = "FILE_TOO_LARGE";
253
+ error.userMessage = params.userMessage ?? null;
254
+ error.details = params.details ?? null;
255
+ throw error;
256
+ }
257
+
258
+ function throwInvalidTimeValueError(params={}) {
259
+ const error = new Error( "Invalid time value" );
260
+ error.code = "INVALID_TIME_VALUE";
261
+ error.userMessage = params.userMessage ?? null;
262
+ error.details = params.details ?? null;
263
+ throw error;
264
+ }