@hla4ts/hla-api 0.1.0

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,971 @@
1
+ /**
2
+ * HLA 4 Exception Classes
3
+ *
4
+ * This module defines the exception hierarchy for HLA 4 (IEEE 1516-2025),
5
+ * mapping protobuf ExceptionData to TypeScript errors.
6
+ *
7
+ * The exception names match the HLA 4 specification exactly.
8
+ */
9
+
10
+ import type { ExceptionData } from "@hla4ts/proto";
11
+
12
+ // =============================================================================
13
+ // Base Exception
14
+ // =============================================================================
15
+
16
+ /**
17
+ * Base class for all HLA exceptions.
18
+ */
19
+ export class RTIexception extends Error {
20
+ constructor(message?: string) {
21
+ super(message);
22
+ this.name = "RTIexception";
23
+ // Maintains proper stack trace for where the error was thrown
24
+ if (Error.captureStackTrace) {
25
+ Error.captureStackTrace(this, this.constructor);
26
+ }
27
+ }
28
+ }
29
+
30
+ /**
31
+ * RTI internal error - indicates an unexpected error within the RTI.
32
+ */
33
+ export class RTIinternalError extends RTIexception {
34
+ constructor(message?: string) {
35
+ super(message);
36
+ this.name = "RTIinternalError";
37
+ }
38
+ }
39
+
40
+ // =============================================================================
41
+ // Connection Exceptions
42
+ // =============================================================================
43
+
44
+ export class AlreadyConnected extends RTIexception {
45
+ constructor(message?: string) {
46
+ super(message);
47
+ this.name = "AlreadyConnected";
48
+ }
49
+ }
50
+
51
+ export class ConnectionFailed extends RTIexception {
52
+ constructor(message?: string) {
53
+ super(message);
54
+ this.name = "ConnectionFailed";
55
+ }
56
+ }
57
+
58
+ export class NotConnected extends RTIexception {
59
+ constructor(message?: string) {
60
+ super(message);
61
+ this.name = "NotConnected";
62
+ }
63
+ }
64
+
65
+ export class Unauthorized extends RTIexception {
66
+ constructor(message?: string) {
67
+ super(message);
68
+ this.name = "Unauthorized";
69
+ }
70
+ }
71
+
72
+ export class InvalidCredentials extends RTIexception {
73
+ constructor(message?: string) {
74
+ super(message);
75
+ this.name = "InvalidCredentials";
76
+ }
77
+ }
78
+
79
+ export class UnsupportedCallbackModel extends RTIexception {
80
+ constructor(message?: string) {
81
+ super(message);
82
+ this.name = "UnsupportedCallbackModel";
83
+ }
84
+ }
85
+
86
+ export class CallNotAllowedFromWithinCallback extends RTIexception {
87
+ constructor(message?: string) {
88
+ super(message);
89
+ this.name = "CallNotAllowedFromWithinCallback";
90
+ }
91
+ }
92
+
93
+ // =============================================================================
94
+ // Federation Management Exceptions
95
+ // =============================================================================
96
+
97
+ export class FederationExecutionAlreadyExists extends RTIexception {
98
+ constructor(message?: string) {
99
+ super(message);
100
+ this.name = "FederationExecutionAlreadyExists";
101
+ }
102
+ }
103
+
104
+ export class FederationExecutionDoesNotExist extends RTIexception {
105
+ constructor(message?: string) {
106
+ super(message);
107
+ this.name = "FederationExecutionDoesNotExist";
108
+ }
109
+ }
110
+
111
+ export class FederatesCurrentlyJoined extends RTIexception {
112
+ constructor(message?: string) {
113
+ super(message);
114
+ this.name = "FederatesCurrentlyJoined";
115
+ }
116
+ }
117
+
118
+ export class FederateAlreadyExecutionMember extends RTIexception {
119
+ constructor(message?: string) {
120
+ super(message);
121
+ this.name = "FederateAlreadyExecutionMember";
122
+ }
123
+ }
124
+
125
+ export class FederateNotExecutionMember extends RTIexception {
126
+ constructor(message?: string) {
127
+ super(message);
128
+ this.name = "FederateNotExecutionMember";
129
+ }
130
+ }
131
+
132
+ export class FederateIsExecutionMember extends RTIexception {
133
+ constructor(message?: string) {
134
+ super(message);
135
+ this.name = "FederateIsExecutionMember";
136
+ }
137
+ }
138
+
139
+ export class FederateNameAlreadyInUse extends RTIexception {
140
+ constructor(message?: string) {
141
+ super(message);
142
+ this.name = "FederateNameAlreadyInUse";
143
+ }
144
+ }
145
+
146
+ export class FederateOwnsAttributes extends RTIexception {
147
+ constructor(message?: string) {
148
+ super(message);
149
+ this.name = "FederateOwnsAttributes";
150
+ }
151
+ }
152
+
153
+ // =============================================================================
154
+ // FOM/MIM Exceptions
155
+ // =============================================================================
156
+
157
+ export class InconsistentFOM extends RTIexception {
158
+ constructor(message?: string) {
159
+ super(message);
160
+ this.name = "InconsistentFOM";
161
+ }
162
+ }
163
+
164
+ export class InvalidFOM extends RTIexception {
165
+ constructor(message?: string) {
166
+ super(message);
167
+ this.name = "InvalidFOM";
168
+ }
169
+ }
170
+
171
+ export class CouldNotOpenFOM extends RTIexception {
172
+ constructor(message?: string) {
173
+ super(message);
174
+ this.name = "CouldNotOpenFOM";
175
+ }
176
+ }
177
+
178
+ export class ErrorReadingFOM extends RTIexception {
179
+ constructor(message?: string) {
180
+ super(message);
181
+ this.name = "ErrorReadingFOM";
182
+ }
183
+ }
184
+
185
+ export class InvalidMIM extends RTIexception {
186
+ constructor(message?: string) {
187
+ super(message);
188
+ this.name = "InvalidMIM";
189
+ }
190
+ }
191
+
192
+ export class CouldNotOpenMIM extends RTIexception {
193
+ constructor(message?: string) {
194
+ super(message);
195
+ this.name = "CouldNotOpenMIM";
196
+ }
197
+ }
198
+
199
+ export class ErrorReadingMIM extends RTIexception {
200
+ constructor(message?: string) {
201
+ super(message);
202
+ this.name = "ErrorReadingMIM";
203
+ }
204
+ }
205
+
206
+ export class DesignatorIsHLAstandardMIM extends RTIexception {
207
+ constructor(message?: string) {
208
+ super(message);
209
+ this.name = "DesignatorIsHLAstandardMIM";
210
+ }
211
+ }
212
+
213
+ // =============================================================================
214
+ // Time Management Exceptions
215
+ // =============================================================================
216
+
217
+ export class CouldNotCreateLogicalTimeFactory extends RTIexception {
218
+ constructor(message?: string) {
219
+ super(message);
220
+ this.name = "CouldNotCreateLogicalTimeFactory";
221
+ }
222
+ }
223
+
224
+ export class FederateUnableToUseTime extends RTIexception {
225
+ constructor(message?: string) {
226
+ super(message);
227
+ this.name = "FederateUnableToUseTime";
228
+ }
229
+ }
230
+
231
+ export class InvalidLogicalTime extends RTIexception {
232
+ constructor(message?: string) {
233
+ super(message);
234
+ this.name = "InvalidLogicalTime";
235
+ }
236
+ }
237
+
238
+ export class InvalidLogicalTimeInterval extends RTIexception {
239
+ constructor(message?: string) {
240
+ super(message);
241
+ this.name = "InvalidLogicalTimeInterval";
242
+ }
243
+ }
244
+
245
+ export class InvalidLookahead extends RTIexception {
246
+ constructor(message?: string) {
247
+ super(message);
248
+ this.name = "InvalidLookahead";
249
+ }
250
+ }
251
+
252
+ export class LogicalTimeAlreadyPassed extends RTIexception {
253
+ constructor(message?: string) {
254
+ super(message);
255
+ this.name = "LogicalTimeAlreadyPassed";
256
+ }
257
+ }
258
+
259
+ export class InTimeAdvancingState extends RTIexception {
260
+ constructor(message?: string) {
261
+ super(message);
262
+ this.name = "InTimeAdvancingState";
263
+ }
264
+ }
265
+
266
+ export class TimeConstrainedAlreadyEnabled extends RTIexception {
267
+ constructor(message?: string) {
268
+ super(message);
269
+ this.name = "TimeConstrainedAlreadyEnabled";
270
+ }
271
+ }
272
+
273
+ export class TimeConstrainedIsNotEnabled extends RTIexception {
274
+ constructor(message?: string) {
275
+ super(message);
276
+ this.name = "TimeConstrainedIsNotEnabled";
277
+ }
278
+ }
279
+
280
+ export class TimeRegulationAlreadyEnabled extends RTIexception {
281
+ constructor(message?: string) {
282
+ super(message);
283
+ this.name = "TimeRegulationAlreadyEnabled";
284
+ }
285
+ }
286
+
287
+ export class TimeRegulationIsNotEnabled extends RTIexception {
288
+ constructor(message?: string) {
289
+ super(message);
290
+ this.name = "TimeRegulationIsNotEnabled";
291
+ }
292
+ }
293
+
294
+ export class RequestForTimeConstrainedPending extends RTIexception {
295
+ constructor(message?: string) {
296
+ super(message);
297
+ this.name = "RequestForTimeConstrainedPending";
298
+ }
299
+ }
300
+
301
+ export class RequestForTimeRegulationPending extends RTIexception {
302
+ constructor(message?: string) {
303
+ super(message);
304
+ this.name = "RequestForTimeRegulationPending";
305
+ }
306
+ }
307
+
308
+ export class IllegalTimeArithmetic extends RTIexception {
309
+ constructor(message?: string) {
310
+ super(message);
311
+ this.name = "IllegalTimeArithmetic";
312
+ }
313
+ }
314
+
315
+ // =============================================================================
316
+ // Save/Restore Exceptions
317
+ // =============================================================================
318
+
319
+ export class SaveInProgress extends RTIexception {
320
+ constructor(message?: string) {
321
+ super(message);
322
+ this.name = "SaveInProgress";
323
+ }
324
+ }
325
+
326
+ export class SaveNotInProgress extends RTIexception {
327
+ constructor(message?: string) {
328
+ super(message);
329
+ this.name = "SaveNotInProgress";
330
+ }
331
+ }
332
+
333
+ export class SaveNotInitiated extends RTIexception {
334
+ constructor(message?: string) {
335
+ super(message);
336
+ this.name = "SaveNotInitiated";
337
+ }
338
+ }
339
+
340
+ export class RestoreInProgress extends RTIexception {
341
+ constructor(message?: string) {
342
+ super(message);
343
+ this.name = "RestoreInProgress";
344
+ }
345
+ }
346
+
347
+ export class RestoreNotInProgress extends RTIexception {
348
+ constructor(message?: string) {
349
+ super(message);
350
+ this.name = "RestoreNotInProgress";
351
+ }
352
+ }
353
+
354
+ export class RestoreNotRequested extends RTIexception {
355
+ constructor(message?: string) {
356
+ super(message);
357
+ this.name = "RestoreNotRequested";
358
+ }
359
+ }
360
+
361
+ export class FederateHasNotBegunSave extends RTIexception {
362
+ constructor(message?: string) {
363
+ super(message);
364
+ this.name = "FederateHasNotBegunSave";
365
+ }
366
+ }
367
+
368
+ // =============================================================================
369
+ // Object Class Exceptions
370
+ // =============================================================================
371
+
372
+ export class ObjectClassNotDefined extends RTIexception {
373
+ constructor(message?: string) {
374
+ super(message);
375
+ this.name = "ObjectClassNotDefined";
376
+ }
377
+ }
378
+
379
+ export class ObjectClassNotPublished extends RTIexception {
380
+ constructor(message?: string) {
381
+ super(message);
382
+ this.name = "ObjectClassNotPublished";
383
+ }
384
+ }
385
+
386
+ export class InvalidObjectClassHandle extends RTIexception {
387
+ constructor(message?: string) {
388
+ super(message);
389
+ this.name = "InvalidObjectClassHandle";
390
+ }
391
+ }
392
+
393
+ // =============================================================================
394
+ // Object Instance Exceptions
395
+ // =============================================================================
396
+
397
+ export class ObjectInstanceNotKnown extends RTIexception {
398
+ constructor(message?: string) {
399
+ super(message);
400
+ this.name = "ObjectInstanceNotKnown";
401
+ }
402
+ }
403
+
404
+ export class ObjectInstanceNameInUse extends RTIexception {
405
+ constructor(message?: string) {
406
+ super(message);
407
+ this.name = "ObjectInstanceNameInUse";
408
+ }
409
+ }
410
+
411
+ export class ObjectInstanceNameNotReserved extends RTIexception {
412
+ constructor(message?: string) {
413
+ super(message);
414
+ this.name = "ObjectInstanceNameNotReserved";
415
+ }
416
+ }
417
+
418
+ export class InvalidObjectInstanceHandle extends RTIexception {
419
+ constructor(message?: string) {
420
+ super(message);
421
+ this.name = "InvalidObjectInstanceHandle";
422
+ }
423
+ }
424
+
425
+ export class DeletePrivilegeNotHeld extends RTIexception {
426
+ constructor(message?: string) {
427
+ super(message);
428
+ this.name = "DeletePrivilegeNotHeld";
429
+ }
430
+ }
431
+
432
+ // =============================================================================
433
+ // Attribute Exceptions
434
+ // =============================================================================
435
+
436
+ export class AttributeNotDefined extends RTIexception {
437
+ constructor(message?: string) {
438
+ super(message);
439
+ this.name = "AttributeNotDefined";
440
+ }
441
+ }
442
+
443
+ export class AttributeNotOwned extends RTIexception {
444
+ constructor(message?: string) {
445
+ super(message);
446
+ this.name = "AttributeNotOwned";
447
+ }
448
+ }
449
+
450
+ export class AttributeNotPublished extends RTIexception {
451
+ constructor(message?: string) {
452
+ super(message);
453
+ this.name = "AttributeNotPublished";
454
+ }
455
+ }
456
+
457
+ export class AttributeAlreadyOwned extends RTIexception {
458
+ constructor(message?: string) {
459
+ super(message);
460
+ this.name = "AttributeAlreadyOwned";
461
+ }
462
+ }
463
+
464
+ export class AttributeAlreadyBeingAcquired extends RTIexception {
465
+ constructor(message?: string) {
466
+ super(message);
467
+ this.name = "AttributeAlreadyBeingAcquired";
468
+ }
469
+ }
470
+
471
+ export class AttributeAlreadyBeingChanged extends RTIexception {
472
+ constructor(message?: string) {
473
+ super(message);
474
+ this.name = "AttributeAlreadyBeingChanged";
475
+ }
476
+ }
477
+
478
+ export class AttributeAlreadyBeingDivested extends RTIexception {
479
+ constructor(message?: string) {
480
+ super(message);
481
+ this.name = "AttributeAlreadyBeingDivested";
482
+ }
483
+ }
484
+
485
+ export class AttributeAcquisitionWasNotRequested extends RTIexception {
486
+ constructor(message?: string) {
487
+ super(message);
488
+ this.name = "AttributeAcquisitionWasNotRequested";
489
+ }
490
+ }
491
+
492
+ export class AttributeDivestitureWasNotRequested extends RTIexception {
493
+ constructor(message?: string) {
494
+ super(message);
495
+ this.name = "AttributeDivestitureWasNotRequested";
496
+ }
497
+ }
498
+
499
+ export class InvalidAttributeHandle extends RTIexception {
500
+ constructor(message?: string) {
501
+ super(message);
502
+ this.name = "InvalidAttributeHandle";
503
+ }
504
+ }
505
+
506
+ // =============================================================================
507
+ // Interaction Class Exceptions
508
+ // =============================================================================
509
+
510
+ export class InteractionClassNotDefined extends RTIexception {
511
+ constructor(message?: string) {
512
+ super(message);
513
+ this.name = "InteractionClassNotDefined";
514
+ }
515
+ }
516
+
517
+ export class InteractionClassNotPublished extends RTIexception {
518
+ constructor(message?: string) {
519
+ super(message);
520
+ this.name = "InteractionClassNotPublished";
521
+ }
522
+ }
523
+
524
+ export class InteractionClassAlreadyBeingChanged extends RTIexception {
525
+ constructor(message?: string) {
526
+ super(message);
527
+ this.name = "InteractionClassAlreadyBeingChanged";
528
+ }
529
+ }
530
+
531
+ export class InteractionParameterNotDefined extends RTIexception {
532
+ constructor(message?: string) {
533
+ super(message);
534
+ this.name = "InteractionParameterNotDefined";
535
+ }
536
+ }
537
+
538
+ export class InvalidInteractionClassHandle extends RTIexception {
539
+ constructor(message?: string) {
540
+ super(message);
541
+ this.name = "InvalidInteractionClassHandle";
542
+ }
543
+ }
544
+
545
+ export class InvalidParameterHandle extends RTIexception {
546
+ constructor(message?: string) {
547
+ super(message);
548
+ this.name = "InvalidParameterHandle";
549
+ }
550
+ }
551
+
552
+ // =============================================================================
553
+ // Federate Handle Exceptions
554
+ // =============================================================================
555
+
556
+ export class FederateHandleNotKnown extends RTIexception {
557
+ constructor(message?: string) {
558
+ super(message);
559
+ this.name = "FederateHandleNotKnown";
560
+ }
561
+ }
562
+
563
+ export class InvalidFederateHandle extends RTIexception {
564
+ constructor(message?: string) {
565
+ super(message);
566
+ this.name = "InvalidFederateHandle";
567
+ }
568
+ }
569
+
570
+ // =============================================================================
571
+ // Ownership Exceptions
572
+ // =============================================================================
573
+
574
+ export class NoAcquisitionPending extends RTIexception {
575
+ constructor(message?: string) {
576
+ super(message);
577
+ this.name = "NoAcquisitionPending";
578
+ }
579
+ }
580
+
581
+ export class OwnershipAcquisitionPending extends RTIexception {
582
+ constructor(message?: string) {
583
+ super(message);
584
+ this.name = "OwnershipAcquisitionPending";
585
+ }
586
+ }
587
+
588
+ // =============================================================================
589
+ // Region Exceptions
590
+ // =============================================================================
591
+
592
+ export class InvalidRegion extends RTIexception {
593
+ constructor(message?: string) {
594
+ super(message);
595
+ this.name = "InvalidRegion";
596
+ }
597
+ }
598
+
599
+ export class InvalidRegionContext extends RTIexception {
600
+ constructor(message?: string) {
601
+ super(message);
602
+ this.name = "InvalidRegionContext";
603
+ }
604
+ }
605
+
606
+ export class RegionNotCreatedByThisFederate extends RTIexception {
607
+ constructor(message?: string) {
608
+ super(message);
609
+ this.name = "RegionNotCreatedByThisFederate";
610
+ }
611
+ }
612
+
613
+ export class RegionDoesNotContainSpecifiedDimension extends RTIexception {
614
+ constructor(message?: string) {
615
+ super(message);
616
+ this.name = "RegionDoesNotContainSpecifiedDimension";
617
+ }
618
+ }
619
+
620
+ export class RegionInUseForUpdateOrSubscription extends RTIexception {
621
+ constructor(message?: string) {
622
+ super(message);
623
+ this.name = "RegionInUseForUpdateOrSubscription";
624
+ }
625
+ }
626
+
627
+ export class InvalidDimensionHandle extends RTIexception {
628
+ constructor(message?: string) {
629
+ super(message);
630
+ this.name = "InvalidDimensionHandle";
631
+ }
632
+ }
633
+
634
+ export class InvalidRangeBound extends RTIexception {
635
+ constructor(message?: string) {
636
+ super(message);
637
+ this.name = "InvalidRangeBound";
638
+ }
639
+ }
640
+
641
+ // =============================================================================
642
+ // Message Retraction Exceptions
643
+ // =============================================================================
644
+
645
+ export class InvalidMessageRetractionHandle extends RTIexception {
646
+ constructor(message?: string) {
647
+ super(message);
648
+ this.name = "InvalidMessageRetractionHandle";
649
+ }
650
+ }
651
+
652
+ export class MessageCanNoLongerBeRetracted extends RTIexception {
653
+ constructor(message?: string) {
654
+ super(message);
655
+ this.name = "MessageCanNoLongerBeRetracted";
656
+ }
657
+ }
658
+
659
+ // =============================================================================
660
+ // Transportation Exceptions
661
+ // =============================================================================
662
+
663
+ export class InvalidTransportationName extends RTIexception {
664
+ constructor(message?: string) {
665
+ super(message);
666
+ this.name = "InvalidTransportationName";
667
+ }
668
+ }
669
+
670
+ export class InvalidTransportationTypeHandle extends RTIexception {
671
+ constructor(message?: string) {
672
+ super(message);
673
+ this.name = "InvalidTransportationTypeHandle";
674
+ }
675
+ }
676
+
677
+ // =============================================================================
678
+ // Order Exceptions
679
+ // =============================================================================
680
+
681
+ export class InvalidOrderName extends RTIexception {
682
+ constructor(message?: string) {
683
+ super(message);
684
+ this.name = "InvalidOrderName";
685
+ }
686
+ }
687
+
688
+ export class InvalidOrderType extends RTIexception {
689
+ constructor(message?: string) {
690
+ super(message);
691
+ this.name = "InvalidOrderType";
692
+ }
693
+ }
694
+
695
+ // =============================================================================
696
+ // Service/Switch Exceptions
697
+ // =============================================================================
698
+
699
+ export class InvalidServiceGroup extends RTIexception {
700
+ constructor(message?: string) {
701
+ super(message);
702
+ this.name = "InvalidServiceGroup";
703
+ }
704
+ }
705
+
706
+ export class InvalidUpdateRateDesignator extends RTIexception {
707
+ constructor(message?: string) {
708
+ super(message);
709
+ this.name = "InvalidUpdateRateDesignator";
710
+ }
711
+ }
712
+
713
+ export class AsynchronousDeliveryAlreadyEnabled extends RTIexception {
714
+ constructor(message?: string) {
715
+ super(message);
716
+ this.name = "AsynchronousDeliveryAlreadyEnabled";
717
+ }
718
+ }
719
+
720
+ export class AsynchronousDeliveryAlreadyDisabled extends RTIexception {
721
+ constructor(message?: string) {
722
+ super(message);
723
+ this.name = "AsynchronousDeliveryAlreadyDisabled";
724
+ }
725
+ }
726
+
727
+ export class FederateServiceInvocationsAreBeingReportedViaMOM extends RTIexception {
728
+ constructor(message?: string) {
729
+ super(message);
730
+ this.name = "FederateServiceInvocationsAreBeingReportedViaMOM";
731
+ }
732
+ }
733
+
734
+ export class ReportServiceInvocationsAreSubscribed extends RTIexception {
735
+ constructor(message?: string) {
736
+ super(message);
737
+ this.name = "ReportServiceInvocationsAreSubscribed";
738
+ }
739
+ }
740
+
741
+ // =============================================================================
742
+ // Synchronization Point Exceptions
743
+ // =============================================================================
744
+
745
+ export class SynchronizationPointLabelNotAnnounced extends RTIexception {
746
+ constructor(message?: string) {
747
+ super(message);
748
+ this.name = "SynchronizationPointLabelNotAnnounced";
749
+ }
750
+ }
751
+
752
+ // =============================================================================
753
+ // Miscellaneous Exceptions
754
+ // =============================================================================
755
+
756
+ export class NameNotFound extends RTIexception {
757
+ constructor(message?: string) {
758
+ super(message);
759
+ this.name = "NameNotFound";
760
+ }
761
+ }
762
+
763
+ export class NameSetWasEmpty extends RTIexception {
764
+ constructor(message?: string) {
765
+ super(message);
766
+ this.name = "NameSetWasEmpty";
767
+ }
768
+ }
769
+
770
+ export class IllegalName extends RTIexception {
771
+ constructor(message?: string) {
772
+ super(message);
773
+ this.name = "IllegalName";
774
+ }
775
+ }
776
+
777
+ export class InvalidResignAction extends RTIexception {
778
+ constructor(message?: string) {
779
+ super(message);
780
+ this.name = "InvalidResignAction";
781
+ }
782
+ }
783
+
784
+ export class CouldNotDecode extends RTIexception {
785
+ constructor(message?: string) {
786
+ super(message);
787
+ this.name = "CouldNotDecode";
788
+ }
789
+ }
790
+
791
+ export class CouldNotEncode extends RTIexception {
792
+ constructor(message?: string) {
793
+ super(message);
794
+ this.name = "CouldNotEncode";
795
+ }
796
+ }
797
+
798
+ /**
799
+ * Exception thrown from within a federate's callback handler.
800
+ */
801
+ export class FederateInternalError extends RTIexception {
802
+ constructor(message?: string) {
803
+ super(message);
804
+ this.name = "FederateInternalError";
805
+ }
806
+ }
807
+
808
+ // =============================================================================
809
+ // Exception Registry and Factory
810
+ // =============================================================================
811
+
812
+ /**
813
+ * Type for exception constructor functions.
814
+ */
815
+ type ExceptionConstructor = new (message?: string) => RTIexception;
816
+
817
+ /**
818
+ * Map of exception names to their constructors.
819
+ */
820
+ const EXCEPTION_REGISTRY: Map<string, ExceptionConstructor> = new Map([
821
+ ["AlreadyConnected", AlreadyConnected],
822
+ ["AsynchronousDeliveryAlreadyDisabled", AsynchronousDeliveryAlreadyDisabled],
823
+ ["AsynchronousDeliveryAlreadyEnabled", AsynchronousDeliveryAlreadyEnabled],
824
+ ["AttributeAcquisitionWasNotRequested", AttributeAcquisitionWasNotRequested],
825
+ ["AttributeAlreadyBeingAcquired", AttributeAlreadyBeingAcquired],
826
+ ["AttributeAlreadyBeingChanged", AttributeAlreadyBeingChanged],
827
+ ["AttributeAlreadyBeingDivested", AttributeAlreadyBeingDivested],
828
+ ["AttributeAlreadyOwned", AttributeAlreadyOwned],
829
+ ["AttributeDivestitureWasNotRequested", AttributeDivestitureWasNotRequested],
830
+ ["AttributeNotDefined", AttributeNotDefined],
831
+ ["AttributeNotOwned", AttributeNotOwned],
832
+ ["AttributeNotPublished", AttributeNotPublished],
833
+ ["CallNotAllowedFromWithinCallback", CallNotAllowedFromWithinCallback],
834
+ ["ConnectionFailed", ConnectionFailed],
835
+ ["CouldNotCreateLogicalTimeFactory", CouldNotCreateLogicalTimeFactory],
836
+ ["CouldNotDecode", CouldNotDecode],
837
+ ["CouldNotEncode", CouldNotEncode],
838
+ ["CouldNotOpenFOM", CouldNotOpenFOM],
839
+ ["CouldNotOpenMIM", CouldNotOpenMIM],
840
+ ["DeletePrivilegeNotHeld", DeletePrivilegeNotHeld],
841
+ ["DesignatorIsHLAstandardMIM", DesignatorIsHLAstandardMIM],
842
+ ["ErrorReadingFOM", ErrorReadingFOM],
843
+ ["ErrorReadingMIM", ErrorReadingMIM],
844
+ ["FederateAlreadyExecutionMember", FederateAlreadyExecutionMember],
845
+ ["FederateHandleNotKnown", FederateHandleNotKnown],
846
+ ["FederateHasNotBegunSave", FederateHasNotBegunSave],
847
+ ["FederateInternalError", FederateInternalError],
848
+ ["FederateIsExecutionMember", FederateIsExecutionMember],
849
+ ["FederateNameAlreadyInUse", FederateNameAlreadyInUse],
850
+ ["FederateNotExecutionMember", FederateNotExecutionMember],
851
+ ["FederateOwnsAttributes", FederateOwnsAttributes],
852
+ ["FederatesCurrentlyJoined", FederatesCurrentlyJoined],
853
+ ["FederateServiceInvocationsAreBeingReportedViaMOM", FederateServiceInvocationsAreBeingReportedViaMOM],
854
+ ["FederateUnableToUseTime", FederateUnableToUseTime],
855
+ ["FederationExecutionAlreadyExists", FederationExecutionAlreadyExists],
856
+ ["FederationExecutionDoesNotExist", FederationExecutionDoesNotExist],
857
+ ["IllegalName", IllegalName],
858
+ ["IllegalTimeArithmetic", IllegalTimeArithmetic],
859
+ ["InconsistentFOM", InconsistentFOM],
860
+ ["InteractionClassAlreadyBeingChanged", InteractionClassAlreadyBeingChanged],
861
+ ["InteractionClassNotDefined", InteractionClassNotDefined],
862
+ ["InteractionClassNotPublished", InteractionClassNotPublished],
863
+ ["InteractionParameterNotDefined", InteractionParameterNotDefined],
864
+ ["InTimeAdvancingState", InTimeAdvancingState],
865
+ ["InvalidAttributeHandle", InvalidAttributeHandle],
866
+ ["InvalidCredentials", InvalidCredentials],
867
+ ["InvalidDimensionHandle", InvalidDimensionHandle],
868
+ ["InvalidFederateHandle", InvalidFederateHandle],
869
+ ["InvalidFOM", InvalidFOM],
870
+ ["InvalidInteractionClassHandle", InvalidInteractionClassHandle],
871
+ ["InvalidLogicalTime", InvalidLogicalTime],
872
+ ["InvalidLogicalTimeInterval", InvalidLogicalTimeInterval],
873
+ ["InvalidLookahead", InvalidLookahead],
874
+ ["InvalidMessageRetractionHandle", InvalidMessageRetractionHandle],
875
+ ["InvalidMIM", InvalidMIM],
876
+ ["InvalidObjectClassHandle", InvalidObjectClassHandle],
877
+ ["InvalidObjectInstanceHandle", InvalidObjectInstanceHandle],
878
+ ["InvalidOrderName", InvalidOrderName],
879
+ ["InvalidOrderType", InvalidOrderType],
880
+ ["InvalidParameterHandle", InvalidParameterHandle],
881
+ ["InvalidRangeBound", InvalidRangeBound],
882
+ ["InvalidRegion", InvalidRegion],
883
+ ["InvalidRegionContext", InvalidRegionContext],
884
+ ["InvalidResignAction", InvalidResignAction],
885
+ ["InvalidServiceGroup", InvalidServiceGroup],
886
+ ["InvalidTransportationName", InvalidTransportationName],
887
+ ["InvalidTransportationTypeHandle", InvalidTransportationTypeHandle],
888
+ ["InvalidUpdateRateDesignator", InvalidUpdateRateDesignator],
889
+ ["LogicalTimeAlreadyPassed", LogicalTimeAlreadyPassed],
890
+ ["MessageCanNoLongerBeRetracted", MessageCanNoLongerBeRetracted],
891
+ ["NameNotFound", NameNotFound],
892
+ ["NameSetWasEmpty", NameSetWasEmpty],
893
+ ["NoAcquisitionPending", NoAcquisitionPending],
894
+ ["NotConnected", NotConnected],
895
+ ["ObjectClassNotDefined", ObjectClassNotDefined],
896
+ ["ObjectClassNotPublished", ObjectClassNotPublished],
897
+ ["ObjectInstanceNameInUse", ObjectInstanceNameInUse],
898
+ ["ObjectInstanceNameNotReserved", ObjectInstanceNameNotReserved],
899
+ ["ObjectInstanceNotKnown", ObjectInstanceNotKnown],
900
+ ["OwnershipAcquisitionPending", OwnershipAcquisitionPending],
901
+ ["RegionDoesNotContainSpecifiedDimension", RegionDoesNotContainSpecifiedDimension],
902
+ ["RegionInUseForUpdateOrSubscription", RegionInUseForUpdateOrSubscription],
903
+ ["RegionNotCreatedByThisFederate", RegionNotCreatedByThisFederate],
904
+ ["ReportServiceInvocationsAreSubscribed", ReportServiceInvocationsAreSubscribed],
905
+ ["RequestForTimeConstrainedPending", RequestForTimeConstrainedPending],
906
+ ["RequestForTimeRegulationPending", RequestForTimeRegulationPending],
907
+ ["RestoreInProgress", RestoreInProgress],
908
+ ["RestoreNotInProgress", RestoreNotInProgress],
909
+ ["RestoreNotRequested", RestoreNotRequested],
910
+ ["RTIexception", RTIexception],
911
+ ["RTIinternalError", RTIinternalError],
912
+ ["SaveInProgress", SaveInProgress],
913
+ ["SaveNotInitiated", SaveNotInitiated],
914
+ ["SaveNotInProgress", SaveNotInProgress],
915
+ ["SynchronizationPointLabelNotAnnounced", SynchronizationPointLabelNotAnnounced],
916
+ ["TimeConstrainedAlreadyEnabled", TimeConstrainedAlreadyEnabled],
917
+ ["TimeConstrainedIsNotEnabled", TimeConstrainedIsNotEnabled],
918
+ ["TimeRegulationAlreadyEnabled", TimeRegulationAlreadyEnabled],
919
+ ["TimeRegulationIsNotEnabled", TimeRegulationIsNotEnabled],
920
+ ["Unauthorized", Unauthorized],
921
+ ["UnsupportedCallbackModel", UnsupportedCallbackModel],
922
+ ]);
923
+
924
+ /**
925
+ * Create an HLA exception from an exception name and details.
926
+ *
927
+ * @param exceptionName - The HLA exception class name (e.g., "NotConnected")
928
+ * @param details - The exception message/details
929
+ * @returns The appropriate RTIexception subclass instance
930
+ */
931
+ export function createException(exceptionName: string, details?: string): RTIexception {
932
+ const Constructor = EXCEPTION_REGISTRY.get(exceptionName);
933
+ if (Constructor) {
934
+ return new Constructor(details);
935
+ }
936
+ // Unknown exception type - wrap as RTIinternalError
937
+ return new RTIinternalError(`${exceptionName}: ${details ?? "Unknown error"}`);
938
+ }
939
+
940
+ /**
941
+ * Create an HLA exception from protobuf ExceptionData.
942
+ *
943
+ * @param exceptionData - The protobuf exception data
944
+ * @returns The appropriate RTIexception subclass instance
945
+ */
946
+ export function createExceptionFromProto(exceptionData: ExceptionData): RTIexception {
947
+ return createException(exceptionData.exceptionName, exceptionData.details);
948
+ }
949
+
950
+ /**
951
+ * Throw an HLA exception from an exception name and details.
952
+ *
953
+ * This is useful for immediately throwing after decoding a response.
954
+ *
955
+ * @param exceptionName - The HLA exception class name
956
+ * @param details - The exception message/details
957
+ * @throws RTIexception or appropriate subclass
958
+ */
959
+ export function throwException(exceptionName: string, details?: string): never {
960
+ throw createException(exceptionName, details);
961
+ }
962
+
963
+ /**
964
+ * Throw an HLA exception from protobuf ExceptionData.
965
+ *
966
+ * @param exceptionData - The protobuf exception data
967
+ * @throws RTIexception or appropriate subclass
968
+ */
969
+ export function throwExceptionFromProto(exceptionData: ExceptionData): never {
970
+ throw createExceptionFromProto(exceptionData);
971
+ }