UNPKG

raygun

Version:

Raygun package for Node.js, written in TypeScript

37 lines (36 loc) 1.33 kB
/* * raygun * https://github.com/MindscapeHQ/raygun4node * * Copyright (c) 2015 MindscapeHQ * Licensed under the MIT license. */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.send = send; var child_process_1 = require("child_process"); var requestProcessSource = require.resolve("./raygun.sync.worker"); function syncRequest(httpOptions) { var requestProcess = (0, child_process_1.spawnSync)("node", [requestProcessSource], { input: JSON.stringify(httpOptions), }); console.log(requestProcess.stdout.toString()); } /** * Spawns a synchronous send request. * Errors are not returned and callback is ignored. * Only used to report uncaught exceptions. * @param options - Send options */ function send(options) { try { syncRequest(options); } catch (e) { // Catch all errors from a synchronous request and display them in the console // This synchronous transport is only used internally to report internal errors, // i.e. uncaught exceptions and unhandled rejection promises. // We need to handle any exceptions internally because the users cannot process these. console.error("[Raygun4Node] Error ".concat(e, " occurred while attempting to send error with message: ").concat(options.message)); } }