File: except_all.cc

package info (click to toggle)
node-addon-api 8.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 15,431; javascript: 5,631; ansic: 157; makefile: 7
file content (22 lines) | stat: -rw-r--r-- 555 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdexcept>
#include "napi.h"

using namespace Napi;

void ThrowStdException(const CallbackInfo& info) {
  std::string message = info[0].As<String>().Utf8Value();
  throw std::runtime_error(message);
}

void ThrowPrimitiveException(const CallbackInfo&) {
  throw 0;
}

Object Init(Env env, Object exports) {
  exports.Set("throwStdException", Napi::Function::New(env, ThrowStdException));
  exports.Set("throwPrimitiveException",
              Napi::Function::New(env, ThrowPrimitiveException));
  return exports;
}

NODE_API_MODULE(addon, Init)