File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,11 +38,7 @@ export default class Almanac {
3838 * @return {Fact }
3939 */
4040 _getFact ( factId ) {
41- let fact = this . factMap . get ( factId )
42- if ( fact === undefined ) {
43- throw new UndefinedFactError ( `Undefined fact: ${ factId } ` )
44- }
45- return fact
41+ return this . factMap . get ( factId )
4642 }
4743
4844 /**
@@ -90,6 +86,9 @@ export default class Almanac {
9086 factValue ( factId , params = { } , path = '' ) {
9187 let factValuePromise
9288 let fact = this . _getFact ( factId )
89+ if ( fact === undefined ) {
90+ return Promise . reject ( new UndefinedFactError ( `Undefined fact: ${ factId } ` ) )
91+ }
9392 if ( fact . isConstant ( ) ) {
9493 factValuePromise = Promise . resolve ( fact . calculate ( params , this ) )
9594 } else {
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ describe('Almanac', () => {
5151 } )
5252
5353 it ( 'throws an exception if it encounters an undefined fact' , ( ) => {
54- return expect ( almanac . factValue ( 'bar' ) ) . to . eventually . be . rejectedWith ( / U n d e f i n e d f a c t : b a r / )
54+ return expect ( almanac . factValue ( 'bar' ) ) . to . be . rejectedWith ( / U n d e f i n e d f a c t : b a r / )
5555 } )
5656 } )
5757
@@ -80,11 +80,6 @@ describe('Almanac', () => {
8080 almanac = new Almanac ( facts )
8181 expect ( almanac . _getFact ( 'id' ) ) . to . equal ( fact )
8282 } )
83-
84- it ( 'raises an exception if fact DNE' , ( ) => {
85- almanac = new Almanac ( new Map ( ) )
86- expect ( almanac . _getFact . bind ( almanac , 'unknown' ) ) . to . throw ( / U n d e f i n e d f a c t / )
87- } )
8883 } )
8984
9085 describe ( '_setFactValue()' , ( ) => {
You can’t perform that action at this time.
0 commit comments