@futdevpro/nts-dynamo 1.6.39 → 1.6.40

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.
@@ -94,14 +94,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
94
94
  return dataListExists;
95
95
  } catch (error) {
96
96
  throw new Dynamo_Error({
97
- status: 417,
97
+ ...this.getDefaultErrorSettings('getAll', error),
98
+
98
99
  errorCode: 'NTS-DS0-GA0',
99
- addECToUserMsg: true,
100
- message: `getAll was unsuccessful (${this.dataParams.dataName})`,
101
- userMessage: this.defaultErrorUserMsg,
102
- issuer: this.issuer,
103
- issuerService: this.serviceName,
104
- error: error
105
100
  });
106
101
  }
107
102
  }
@@ -126,13 +121,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
126
121
  try {
127
122
  if (!id && !this.data._id) {
128
123
  throw new Dynamo_Error({
129
- status: 417,
124
+ ...this.getDefaultErrorSettings(
125
+ 'getDataById',
126
+ new Error(`getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`)
127
+ ),
128
+
130
129
  errorCode: 'NTS-DS0-GI1',
131
- addECToUserMsg: true,
132
- message: `getDataById failed, ID is missing! (maybe you wanted to use getDataByDependencyId() instead...) (${this.dataParams.dataName})`,
133
- userMessage: this.defaultErrorUserMsg,
134
- issuer: this.issuer,
135
- issuerService: this.serviceName,
136
130
  });
137
131
  }
138
132
 
@@ -147,14 +141,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
147
141
  throw error;
148
142
  } else {
149
143
  throw new Dynamo_Error({
150
- status: 417,
144
+ ...this.getDefaultErrorSettings('getDataById', error),
145
+
151
146
  errorCode: 'NTS-DS0-GI0',
152
- addECToUserMsg: true,
153
- message: `getDataById was unsuccessful (${this.dataParams.dataName})`,
154
- userMessage: this.defaultErrorUserMsg,
155
- issuer: this.issuer,
156
- issuerService: this.serviceName,
157
- error: error
158
147
  });
159
148
  }
160
149
  }
@@ -169,25 +158,23 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
169
158
  try {
170
159
  if (!this.depKey) {
171
160
  throw new Dynamo_Error({
172
- status: 417,
161
+ ...this.getDefaultErrorSettings(
162
+ 'getDataByDependencyId',
163
+ new Error(`getDataByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
164
+ ),
165
+
173
166
  errorCode: 'NTS-DS0-GD1',
174
- addECToUserMsg: true,
175
- message: `getDataByDependencyId failed, dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
176
- userMessage: this.defaultErrorUserMsg,
177
- issuer: this.issuer,
178
- issuerService: this.serviceName,
179
167
  });
180
168
  }
181
169
 
182
170
  if (!dependencyId && !this.data[this.depKey]) {
183
171
  throw new Dynamo_Error({
184
- status: 417,
172
+ ...this.getDefaultErrorSettings(
173
+ 'getDataByDependencyId',
174
+ new Error(`getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
175
+ ),
176
+
185
177
  errorCode: 'NTS-DS0-GD2',
186
- addECToUserMsg: true,
187
- message: `getDataByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`,
188
- userMessage: this.defaultErrorUserMsg,
189
- issuer: this.issuer,
190
- issuerService: this.serviceName,
191
178
  });
192
179
  }
193
180
 
@@ -209,14 +196,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
209
196
  throw error;
210
197
  } else {
211
198
  throw new Dynamo_Error({
212
- status: 417,
199
+ ...this.getDefaultErrorSettings('getDataByDependencyId', error),
200
+
213
201
  errorCode: 'NTS-DS0-GD0',
214
- addECToUserMsg: true,
215
- message: `getDataByDependencyId was unsuccessful (${this.dataParams.dataName})`,
216
- userMessage: this.defaultErrorUserMsg,
217
- issuer: this.issuer,
218
- issuerService: this.serviceName,
219
- error: error
220
202
  });
221
203
  }
222
204
  }
@@ -230,25 +212,23 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
230
212
  try {
231
213
  if (!this.depKey) {
232
214
  throw new Dynamo_Error({
233
- status: 417,
215
+ ...this.getDefaultErrorSettings(
216
+ 'getDataListByDependencyId',
217
+ new Error(`getDataListByDependencyId failed, dependencyKey is missing from service! (${this.dataParams.dataName})`)
218
+ ),
219
+
234
220
  errorCode: 'NTS-DS0-GLD1',
235
- addECToUserMsg: true,
236
- message: `dependencyDataIdKey is missing from service! (${this.dataParams.dataName})`,
237
- userMessage: this.defaultErrorUserMsg,
238
- issuer: this.issuer,
239
- issuerService: this.serviceName,
240
221
  });
241
222
  }
242
223
 
243
224
  if (!dependencyId && !this.data[this.depKey]) {
244
225
  throw new Dynamo_Error({
245
- status: 417,
226
+ ...this.getDefaultErrorSettings(
227
+ 'getDataListByDependencyId',
228
+ new Error(`getDataListByDependencyId failed, ${this.depKey} is missing! (${this.dataParams.dataName})`)
229
+ ),
230
+
246
231
  errorCode: 'NTS-DS0-GLD2',
247
- addECToUserMsg: true,
248
- message: `getDataListByDependencyId failed, ${this.depKey} is missing (${this.dataParams.dataName})`,
249
- userMessage: this.defaultErrorUserMsg,
250
- issuer: this.issuer,
251
- issuerService: this.serviceName,
252
232
  });
253
233
  }
254
234
 
@@ -270,14 +250,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
270
250
  throw error;
271
251
  } else {
272
252
  throw new Dynamo_Error({
273
- status: 417,
253
+ ...this.getDefaultErrorSettings('getDataListByDependencyId', error),
254
+
274
255
  errorCode: 'NTS-DS0-GLD0',
275
- addECToUserMsg: true,
276
- message: `getDataListByDependencyId was unsuccessful (${this.dataParams.dataName})`,
277
- userMessage: this.defaultErrorUserMsg,
278
- issuer: this.issuer,
279
- issuerService: this.serviceName,
280
- error: error
281
256
  });
282
257
  }
283
258
  }
@@ -330,14 +305,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
330
305
  return dataExists;
331
306
  } catch (error) {
332
307
  throw new Dynamo_Error({
333
- status: 417,
308
+ ...this.getDefaultErrorSettings('findData', error),
309
+
334
310
  errorCode: 'NTS-DS0-FD0',
335
- addECToUserMsg: true,
336
- message: `findData was unsuccessful (${this.dataParams.dataName})`,
337
- userMessage: this.defaultErrorUserMsg,
338
- issuer: this.issuer,
339
- issuerService: this.serviceName,
340
- error: error
341
311
  });
342
312
  }
343
313
  }
@@ -389,14 +359,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
389
359
  return dataListExists;
390
360
  } catch (error) {
391
361
  throw new Dynamo_Error({
392
- status: 417,
362
+ ...this.getDefaultErrorSettings('findDatas', error),
363
+
393
364
  errorCode: 'NTS-DS0-FDS0',
394
- addECToUserMsg: true,
395
- message: `findDatas was unsuccessful (${this.dataParams.dataName})`,
396
- userMessage: this.defaultErrorUserMsg,
397
- issuer: this.issuer,
398
- issuerService: this.serviceName,
399
- error: error
400
365
  });
401
366
  }
402
367
  }
@@ -467,13 +432,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
467
432
  await this.dataDBService.updateOne({ [this.depKey]: this.data[this.depKey] } as DynamoNTS_DBFilter<T>, set.update, this.issuer);
468
433
  } else {
469
434
  throw new Dynamo_Error({
470
- status: 417,
435
+ ...this.getDefaultErrorSettings(
436
+ 'updateData',
437
+ new Error(`no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`)
438
+ ),
439
+
471
440
  errorCode: 'NTS-DS0-UD1',
472
- addECToUserMsg: true,
473
- message: `no usable parameter provided for updateData; no updateBy, no id, no dependencyId (${this.dataParams.dataName})`,
474
- userMessage: this.defaultErrorUserMsg,
475
- issuer: this.issuer,
476
- issuerService: this.serviceName,
477
441
  });
478
442
  }
479
443
  } catch (error) {
@@ -481,14 +445,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
481
445
  throw error;
482
446
  } else {
483
447
  throw new Dynamo_Error({
484
- status: 417,
448
+ ...this.getDefaultErrorSettings('updateData', error),
449
+
485
450
  errorCode: 'NTS-DS0-UD0',
486
- addECToUserMsg: true,
487
- message: `updateData was unsuccessful (${this.dataParams.dataName})`,
488
- userMessage: this.defaultErrorUserMsg,
489
- issuer: this.issuer,
490
- issuerService: this.serviceName,
491
- error: error
492
451
  });
493
452
  }
494
453
  }
@@ -509,13 +468,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
509
468
  try {
510
469
  if (!this.data) {
511
470
  throw new Dynamo_Error({
512
- status: 417,
471
+ ...this.getDefaultErrorSettings('saveData', new Error(`no data to save! (${this.dataParams.dataName})`)),
472
+
513
473
  errorCode: 'NTS-DS0-SD4',
514
- addECToUserMsg: true,
515
- message: `saveData was unsuccessful: no data to save!, (${this.dataParams.dataName})`,
516
- userMessage: this.defaultErrorUserMsg,
517
- issuer: this.issuer,
518
- issuerService: this.serviceName,
519
474
  });
520
475
  }
521
476
 
@@ -536,13 +491,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
536
491
  return;
537
492
  } else {
538
493
  throw new Dynamo_Error({
539
- status: 417,
494
+ ...this.getDefaultErrorSettings(
495
+ 'saveData',
496
+ new Error(`saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`)
497
+ ),
498
+
540
499
  errorCode: 'NTS-DS0-SD1',
541
- addECToUserMsg: true,
542
- message: `saveData was unsuccessful: provided ID not exists (id: ${this.data._id}, ${this.dataParams.dataName})`,
543
- userMessage: this.defaultErrorUserMsg,
544
- issuer: this.issuer,
545
- issuerService: this.serviceName,
546
500
  });
547
501
  }
548
502
  }
@@ -550,13 +504,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
550
504
  if (this.depKey) {
551
505
  if (!this.data[this.depKey]) {
552
506
  throw new Dynamo_Error({
553
- status: 417,
507
+ ...this.getDefaultErrorSettings(
508
+ 'saveData',
509
+ new Error(`saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`)
510
+ ),
511
+
554
512
  errorCode: 'NTS-DS0-SD2',
555
- addECToUserMsg: true,
556
- message: `saveData was unsuccessful: dependency data id missing from data (key: ${this.depKey}, ${this.dataParams.dataName})`,
557
- userMessage: this.defaultErrorUserMsg,
558
- issuer: this.issuer,
559
- issuerService: this.serviceName,
560
513
  });
561
514
  }
562
515
 
@@ -572,13 +525,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
572
525
  const dependencyExists = await this.getDependencyDataDBService().getDataById(this.data[this.depKey]);
573
526
  if(!dependencyExists) {
574
527
  throw new Dynamo_Error({
575
- status: 417,
528
+ ...this.getDefaultErrorSettings(
529
+ 'saveData',
530
+ new Error(`saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`)
531
+ ),
532
+
576
533
  errorCode: 'NTS-DS0-SD3',
577
- addECToUserMsg: true,
578
- message: `saveData was unsuccessful: dependency data not exists (key: ${this.depKey}, id: ${this.data[this.depKey]}, ${this.dataParams.dataName})`,
579
- userMessage: this.defaultErrorUserMsg,
580
- issuer: this.issuer,
581
- issuerService: this.serviceName,
582
534
  });
583
535
  }
584
536
  }
@@ -593,14 +545,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
593
545
  throw error;
594
546
  } else {
595
547
  throw new Dynamo_Error({
596
- status: 417,
548
+ ...this.getDefaultErrorSettings('saveData', error),
549
+
597
550
  errorCode: 'NTS-DS0-SD0',
598
- addECToUserMsg: true,
599
- message: `saveData was unsuccessful (${this.dataParams.dataName})`,
600
- userMessage: this.defaultErrorUserMsg,
601
- issuer: this.issuer,
602
- issuerService: this.serviceName,
603
- error: error
604
551
  });
605
552
  }
606
553
  }
@@ -613,13 +560,12 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
613
560
  try {
614
561
  if (!this.data._id) {
615
562
  throw new Dynamo_Error({
616
- status: 417,
563
+ ...this.getDefaultErrorSettings(
564
+ 'deleteData',
565
+ new Error(`deleteData failed, ID is missing! (${this.dataParams.dataName})`)
566
+ ),
567
+
617
568
  errorCode: 'NTS-DS0-DD1',
618
- addECToUserMsg: true,
619
- message: `deleteData failed, ID is missing! (${this.dataParams.dataName})` ,
620
- userMessage: this.defaultErrorUserMsg,
621
- issuer: this.issuer,
622
- issuerService: this.serviceName,
623
569
  });
624
570
  }
625
571
 
@@ -629,14 +575,9 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
629
575
  throw error;
630
576
  } else {
631
577
  throw new Dynamo_Error({
632
- status: 417,
578
+ ...this.getDefaultErrorSettings('deleteData', error),
579
+
633
580
  errorCode: 'NTS-DS0-DD0',
634
- addECToUserMsg: true,
635
- message: `deleteData was unsuccessful (${this.dataParams.dataName})`,
636
- userMessage: this.defaultErrorUserMsg,
637
- issuer: this.issuer,
638
- issuerService: this.serviceName,
639
- error: error
640
581
  });
641
582
  }
642
583
  }
@@ -661,13 +602,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
661
602
  )
662
603
  ) {
663
604
  throw new Dynamo_Error({
605
+ ...this.getDefaultErrorSettings(
606
+ 'validateForSave',
607
+ new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.dataName})`)
608
+ ),
609
+
664
610
  status: 422,
665
611
  errorCode: 'NTS-DS0-VD1',
666
- addECToUserMsg: true,
667
- message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is missing! (${this.dataParams.modelParams[i].required ? 'required' : 'index'}) (${this.dataParams.dataName})`,
668
612
  userMessage: this.defaultValidationErrorUserMsg,
669
- issuer: this.issuer,
670
- issuerService: this.serviceName,
671
613
  });
672
614
  }
673
615
 
@@ -676,13 +618,14 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
676
618
  !(new Date(this.data[this.dataParams.modelParams[i].key]) instanceof Date)
677
619
  ) {
678
620
  throw new Dynamo_Error({
621
+ ...this.getDefaultErrorSettings(
622
+ 'validateForSave',
623
+ new Error(`validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`)
624
+ ),
625
+
679
626
  status: 422,
680
627
  errorCode: 'NTS-DS0-VD2',
681
- addECToUserMsg: true,
682
- message: `validateForSave failed, ${this.dataParams.modelParams[i].key} is not a date! (${this.dataParams.dataName})`,
683
628
  userMessage: this.defaultValidationErrorUserMsg,
684
- issuer: this.issuer,
685
- issuerService: this.serviceName,
686
629
  });
687
630
  }
688
631
 
@@ -698,14 +641,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
698
641
  throw error;
699
642
  } else {
700
643
  throw new Dynamo_Error({
644
+ ...this.getDefaultErrorSettings('validateForSave', error),
645
+
701
646
  status: 422,
702
647
  errorCode: 'NTS-DS0-VD0',
703
- addECToUserMsg: true,
704
- message: `validateForSave was unsuccessful (${this.dataParams.dataName})`,
705
- userMessage: this.defaultErrorUserMsg,
706
- issuer: this.issuer,
707
- issuerService: this.serviceName,
708
- error: error
709
648
  });
710
649
  }
711
650
  }
@@ -736,13 +675,13 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
736
675
  getDependencyDataDBService(): DynamoNTS_DBService<any> {
737
676
  if (!this.depDBServiceKey) {
738
677
  throw new Dynamo_Error({
678
+ ...this.getDefaultErrorSettings(
679
+ 'getDependencyDataDBService',
680
+ new Error(`getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`)
681
+ ),
682
+
739
683
  status: 501,
740
684
  errorCode: 'NTS-DS0-GDDB0',
741
- addECToUserMsg: true,
742
- message: `getDependencyDataDBService was unsuccessful, service key not setted up! (${this.dataParams.dataName}))`,
743
- userMessage: this.defaultErrorUserMsg,
744
- issuer: this.issuer,
745
- issuerService: this.serviceName,
746
685
  });
747
686
  }
748
687
 
@@ -753,4 +692,16 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
753
692
  return this.depDataDBService;
754
693
  }
755
694
  }
695
+
696
+ private getDefaultErrorSettings(fnName: string, error?: Error | Dynamo_Error) {
697
+ return {
698
+ status: 417,
699
+ message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS; ${this.dataParams.dataName})`,
700
+ addECToUserMsg: true,
701
+ userMessage: this.defaultErrorUserMsg,
702
+ issuer: this.issuer,
703
+ issuerService: this.serviceName,
704
+ error: error,
705
+ }
706
+ }
756
707
  }
@@ -531,15 +531,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
531
531
  });
532
532
  });
533
533
 
534
- if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
535
- data._id = `${data._id}`;
536
- if (typeof data._id !== 'string' || typeof data._id === 'object') {
537
- data = JSON.parse(JSON.stringify(data));
538
- if (typeof data._id !== 'string' || typeof data._id === 'object') {
539
- Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
540
- }
541
- }
542
- }
534
+ data = this.stringifyDataId(data);
543
535
 
544
536
  return data;
545
537
  }
@@ -830,6 +822,25 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
830
822
 
831
823
  // ----------------------------------------------------------------------------------
832
824
  // ----------------------------------------------------------------------------------
825
+ // ----------------------------------------------------------------------------------
826
+ // PRIVATE FUNCTIONS
827
+
828
+ private stringifyDataId(data: T): T {
829
+ if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
830
+ data._id = `${data._id}`;
831
+
832
+ if (typeof data._id !== 'string' || typeof data._id === 'object') {
833
+ data = JSON.parse(JSON.stringify(data));
834
+
835
+ if (typeof data._id !== 'string' || typeof data._id === 'object') {
836
+ Dynamo_Log.error('data._id stringifying failed! Please notfiy the developers!', new Error());
837
+ }
838
+ }
839
+ }
840
+
841
+ return data;
842
+ }
843
+
833
844
  // ----------------------------------------------------------------------------------
834
845
  // PRIVATE BUILD FUNCTIONS
835
846
 
@@ -6,7 +6,7 @@ import * as Https from 'https';
6
6
  import * as FileSystem from 'fs';
7
7
  import * as BodyParser from 'body-parser';
8
8
 
9
- import { Dynamo_Array, Dynamo_Error, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
9
+ import { Dynamo_Array, Dynamo_Error, dynamo_error_default, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
10
10
 
11
11
  import { DynamoNTS_SingletonService } from '../base/singleton.service';
12
12
  import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
@@ -230,13 +230,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
230
230
  if (this.logFn && this.deepLog) console.log('\nfn:. asyncConstruct');
231
231
  try {
232
232
  this.systemControls.app.init = true;
233
- this.logSetup = dynamoNTS_globalSettings.logSetup;
234
233
  this._params = this.getAppParams();
235
-
234
+ dynamo_error_default.issuerSystem = this._params.name;
236
235
 
237
236
  if (this.overrideDynamoNTSGlobalSettings) {
238
237
  this.overrideDynamoNTSGlobalSettings();
239
238
  }
239
+ this.logSetup = dynamoNTS_globalSettings.logSetup;
240
240
 
241
241
  this.globalService = DynamoNTS_GlobalService.getInstance();
242
242
  DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
@@ -320,23 +320,30 @@ export abstract class DynamoNTS_SocketServerService<
320
320
  async sendEventForId(id: string, event: string, content: any/* , error?: (err: any) => void */): Promise<void> {
321
321
  try {
322
322
  const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
323
+
323
324
  if (presence) {
324
325
  Dynamo_Log.log(` <--- emitting socket event for presence: ${event} (${this.params.name}, presenceId: ${id})`);
325
326
  presence.emitEvent(event, content);
326
327
  } else {
327
- /* if (error) { */
328
328
  throw new Dynamo_Error({
329
+ ...this.getDefaultErrorSettings(
330
+ 'sendEventForId',
331
+ new Error(`No active socket whit this specific ID: ${id}`),
332
+ content?.source
333
+ ),
334
+
329
335
  status: 404,
330
- errorCode: 'NTS-S99-001',
331
- addECToUserMsg: true,
332
- message: `No active socket whit this specific ID: ${id}`,
333
- userMessage: this.defaultErrorUserMsg
336
+ errorCode: 'NTS-SSS-301',
334
337
  });
335
- /* } */
336
338
  }
337
339
  } catch (error) {
338
- Dynamo_Log.error(`Socket Event Emit for id (${id}, ${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
339
- throw error;
340
+ throw new Dynamo_Error({
341
+ ...this.getDefaultErrorSettings('sendEventForId', error, content?.source),
342
+
343
+ errorCode: 'NTS-SSS-300',
344
+ message: `Socket Event Emit for id (${id}, ${event}) failed: ${this.params?.name} (${this.params?.port})`,
345
+ error
346
+ });
340
347
  }
341
348
  }
342
349
 
@@ -347,7 +354,25 @@ export abstract class DynamoNTS_SocketServerService<
347
354
  });
348
355
  } catch (error) {
349
356
  Dynamo_Log.error(`Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
350
- throw error;
357
+ throw new Dynamo_Error({
358
+ ...this.getDefaultErrorSettings('broadcastEvent', error),
359
+
360
+ errorCode: 'NTS-SSS-400',
361
+ message: `Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`,
362
+ error
363
+ });
364
+ }
365
+ }
366
+
367
+ private getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error, issuer?: string) {
368
+ return {
369
+ status: 417,
370
+ message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
371
+ addECToUserMsg: true,
372
+ userMessage: this.defaultErrorUserMsg,
373
+ issuer: issuer,
374
+ issuerService: this.constructor?.name,
375
+ error: error,
351
376
  }
352
377
  }
353
378