11import { AWS_REGIONS } from './aws-entities' ;
2+ import { UnscopedValidationError } from '../../core' ;
23
34/**
45 * A database of regional information.
@@ -56,7 +57,7 @@ export class Fact {
5657 const foundFact = this . find ( region , name ) ;
5758
5859 if ( ! foundFact ) {
59- throw new Error ( `No fact ${ name } could be found for region: ${ region } and name: ${ name } .` ) ;
60+ throw new UnscopedValidationError ( `No fact ${ name } could be found for region: ${ region } and name: ${ name } .` ) ;
6061 }
6162
6263 return foundFact ;
@@ -71,7 +72,7 @@ export class Fact {
7172 public static register ( fact : IFact , allowReplacing = false ) : void {
7273 const regionFacts = this . database [ fact . region ] || ( this . database [ fact . region ] = { } ) ;
7374 if ( fact . name in regionFacts && regionFacts [ fact . name ] !== fact . value && ! allowReplacing ) {
74- throw new Error ( `Region ${ fact . region } already has a fact ${ fact . name } , with value ${ regionFacts [ fact . name ] } ` ) ;
75+ throw new UnscopedValidationError ( `Region ${ fact . region } already has a fact ${ fact . name } , with value ${ regionFacts [ fact . name ] } ` ) ;
7576 }
7677 if ( fact . value !== undefined ) {
7778 regionFacts [ fact . name ] = fact . value ;
@@ -88,15 +89,15 @@ export class Fact {
8889 public static unregister ( region : string , name : string , value ?: string ) : void {
8990 const regionFacts = this . database [ region ] || { } ;
9091 if ( name in regionFacts && value && regionFacts [ name ] !== value ) {
91- throw new Error ( `Attempted to remove ${ name } from ${ region } with value ${ value } , but the fact's value is ${ regionFacts [ name ] } ` ) ;
92+ throw new UnscopedValidationError ( `Attempted to remove ${ name } from ${ region } with value ${ value } , but the fact's value is ${ regionFacts [ name ] } ` ) ;
9293 }
9394 delete regionFacts [ name ] ;
9495 }
9596
9697 private static readonly database : { [ region : string ] : { [ name : string ] : string } } = { } ;
9798
9899 private constructor ( ) {
99- throw new Error ( 'Use the static methods of Fact instead!' ) ;
100+ throw new UnscopedValidationError ( 'Use the static methods of Fact instead!' ) ;
100101 }
101102}
102103
0 commit comments