From f2944e0bae098cf782b0fbb1e7931c0df1d2583b Mon Sep 17 00:00:00 2001 From: ncannasse Date: Fri, 2 Mar 2018 17:26:12 +0100 Subject: [PATCH] added rethrow() --- hscript/Interp.hx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index db2d924..75e0d8c 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -288,13 +288,18 @@ class Interp { #end } - inline function error(e : #if hscriptPos ErrorDef #else Error #end ) : Dynamic { - #if hscriptPos - throw new Error(e, curExpr.pmin, curExpr.pmax, curExpr.origin, curExpr.line); + inline function error(e : #if hscriptPos ErrorDef #else Error #end, rethrow=false ) : Dynamic { + #if hscriptPos var e = new Error(e, curExpr.pmin, curExpr.pmax, curExpr.origin, curExpr.line); #end + if( rethrow ) this.rethrow(e) else throw e; + return null; + } + + inline function rethrow( e : Dynamic ) { + #if hl + hl.Api.rethrow(e); #else throw e; #end - return null; } function resolve( id : String ) : Dynamic {