Innovenergy_trunk/frontend/node_modules/testcafe/lib/errors/get-callsite.js

32 lines
4.4 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCallsiteForError = exports.getCallsiteForMethod = void 0;
const callsite_record_1 = __importDefault(require("callsite-record"));
const stack_cleaning_hook_1 = __importDefault(require("./stack-cleaning-hook"));
const source_map_support_1 = require("source-map-support");
const STACK_TRACE_LIMIT = 2000;
function getCallsite(options) {
const originalStackCleaningEnabled = stack_cleaning_hook_1.default.enabled;
const originalStackTraceLimit = Error.stackTraceLimit;
stack_cleaning_hook_1.default.enabled = false;
Error.stackTraceLimit = STACK_TRACE_LIMIT;
const callsiteRecord = (0, callsite_record_1.default)(options);
Error.stackTraceLimit = originalStackTraceLimit;
stack_cleaning_hook_1.default.enabled = originalStackCleaningEnabled;
return callsiteRecord;
}
function getCallsiteForMethod(methodName, typeName) {
return getCallsite({ byFunctionName: methodName, typeName, processFrameFn: source_map_support_1.wrapCallSite });
}
exports.getCallsiteForMethod = getCallsiteForMethod;
function getCallsiteForError(error, isCallsiteFrame) {
// NOTE: "source-map-support" process this kind of error automatically, cause
// in this case there is an appeal to "err.stack" inside "callsite-record" which
// provokes wrapping of frames, so there is no need to specify "processFrameFn".
return getCallsite({ forError: error, isCallsiteFrame });
}
exports.getCallsiteForError = getCallsiteForError;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0LWNhbGxzaXRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Vycm9ycy9nZXQtY2FsbHNpdGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsc0VBQW1EO0FBQ25ELGdGQUFzRDtBQUN0RCwyREFBa0Q7QUFFbEQsTUFBTSxpQkFBaUIsR0FBRyx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