@@ -4,6 +4,7 @@ import type { BinaryDecisionDiagram } from "./bdd/BinaryDecisionDiagram";
44import type { EndpointResolverOptions } from "./types" ;
55import { EndpointError } from "./types" ;
66import { evaluateCondition } from "./utils/evaluateCondition" ;
7+ import { evaluateExpression } from "./utils/evaluateExpression" ;
78import { getEndpointHeaders } from "./utils/getEndpointHeaders" ;
89import { getEndpointProperties } from "./utils/getEndpointProperties" ;
910import { getEndpointUrl } from "./utils/getEndpointUrl" ;
@@ -40,15 +41,15 @@ export const decideEndpoint = (bdd: BinaryDecisionDiagram, options: EndpointReso
4041 if ( ref >= RESULT ) {
4142 const result = results [ ref - RESULT ] ;
4243 if ( result [ 0 ] === - 1 ) {
43- const [ , errorMessage ] = result ;
44- throw new EndpointError ( errorMessage ! ) ;
44+ const [ , errorExpression ] = result ;
45+ throw new EndpointError ( evaluateExpression ( errorExpression ! , "Error" , closure ) as string ) ;
4546 }
4647 const [ url , properties , headers ] = result ;
4748
4849 return {
4950 url : getEndpointUrl ( url , closure ) ,
5051 properties : getEndpointProperties ( properties , closure ) ,
51- headers : getEndpointHeaders ( headers , closure ) ,
52+ headers : getEndpointHeaders ( headers ?? { } , closure ) ,
5253 } ;
5354 }
5455
0 commit comments