LiquidPlayer / LiquidCore

Node.js virtual machine for Android and iOS
MIT License
1.01k stars 127 forks source link

Can't find exception message text #134

Open str11ngfello opened 4 years ago

str11ngfello commented 4 years ago

Hi. Been working with LiquidCore for a few days. Great work!

I can't find a way to get the ACTUAL exception text during development though when an exception is thrown by a library I'm using. I explicitly catch an error with a try/catch and log the error, which looks like this ->

2019-10-18 09:26:15.348623-0500 lq[29678:105717] stdout: ### Global Catch ### { checkDecode@liquid.bundle.js:14226:22 parseKey@liquid.bundle.js:14571:44 liquid.bundle.js:14653:20 JsSignatureProvider@liquid.bundle.js:8645:85 liquid.bundle.js:8222:72 step@liquid.bundle.js:8141:23 fulfilled@liquid.bundle.js:8024:30 promiseReactionJob@[native code] [native code] Function emitAfterScript@async_hooks.js:449:14 _tickCallback@internal/process/next_tick.js:182:18 line: 14226, column: 22, sourceURL: 'liquid.bundle.js' }

That stack trace is pretty useful. But, to find the exception text I have to lookup line 14226 by generating the code on the server endpoint. Copy that text from browser to Visual Code and find the line number. I eventually find the throwing exception (although obviously I don't have the interpolated values that come with it). Here's line 14226 that throws:


    if (checksum.toString() !== newCheck.toString()) {
     (line 14226) throw new Error('Invalid checksum, ' + (checksum.toString('hex') + ' != ' + newCheck.toString('hex')));
    }

How can I get the actual error text of "Invalid Checksum ... blah blah blah " when I log to the console? My try/catch simples catches (e) and prints the whole thing. I hope I'm just missing something very simple it would really help debugging. Thanks.

My try/catch is simply:

catch (e) {
        console.log('### Global Catch ###', e)
    }
ericwlange commented 4 years ago

I know this is a late reply. But if this is still relevant, you can always console.log(e.message) to get the actual human error message.