hileez/node-pyrunner

How to handle error in python or js

Closed this issue · 1 comments

  • PyRunner Version

1.0.5

  • Code Template 1

python

...
def hello()
  rasie Exception('error')
  return 'hello from python'

js

appModule.call('hello', [],
  (data) => {
     consolo.log(data)
  },
  (err) => {
    console.log(err)
  }
)
  • Error

node process exit with code 1

  • Code Template 2

python

import nodepyrunner
...
try:
  nodepyrunner.callJs(target='hello', args=[])
except:
  print('some err')

js

global.hello = () => {
  throw Error()
}
  • Error

FATAL ERROR: Error::New napi_get_last_error_info
1: 00007FF7E15FB34F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+123599
2: 00007FF7E1588CB6 v8::internal::MicrotaskQueue::GetMicrotasksScopeDepth+65206
3: 00007FF7E1589D8D node::OnFatalError+301
4: 00007FF7E1589369 v8::internal::MicrotaskQueue::GetMicrotasksScopeDepth+66921
5: 00007FF7E15B73FC napi_fatal_error+156
...

Node process ended because of python and javascript throw error.
Python和JavaScript抛出异常都会导致node进程结束。