Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I override or bubble up javascript try/catch blocks

Tags:

javascript

I have an application that uses a few external libraries. These libraries use try/catch blocks to deal with errors. Rather then editing the libraries and removing the try/catch blocks is there a way to force them to bubble up to a function I control so that I can post them to my server?

here is an example

'parseBindingsString': function(bindingsString, bindingContext, node, options) {
        try {
            var bindingFunction = createBindingsStringEvaluatorViaCache(bindingsString, this.bindingCache, options);
            return bindingFunction(bindingContext, node);
        } catch (ex) {
            ex.message = "Unable to parse bindings.\nBindings value: " + bindingsString + "\nMessage: " + ex.message;
            throw ex;
        }
    }
like image 502
Hayden Chambers Avatar asked Sep 02 '25 02:09

Hayden Chambers


1 Answers

Nope. If an Exception is thrown and catched, it won't bubble up again (unless the catch blocks rethrows the exception).

like image 136
Madara's Ghost Avatar answered Sep 04 '25 21:09

Madara's Ghost