Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
process.on('uncaughtException', (err: Error) => {
logger.error(`Uncaught Exception: ${err && err.message ? err.message : ''}`);
logger.error(err && err.name ? err.name : '');
logger.error(err && err.stack ? err.stack : '');
// Catch all, incase we have string exceptions being raised.
logger.error(err ? err.toString() : '');
// Wait for 1 second before we die, we need to ensure errors are written to the log file.
setTimeout(() => process.exit(-1), 100);
});
process.on('uncaughtException', (err: Error) => {
logger.error(`Uncaught Exception: ${err && err.message ? err.message : ''}`);
logger.error(err && err.name ? err.name : '');
logger.error(err && err.stack ? err.stack : '');
// Catch all, incase we have string exceptions being raised.
logger.error(err ? err.toString() : '');
// Wait for 1 second before we die, we need to ensure errors are written to the log file.
setTimeout(() => process.exit(-1), 100);
});
process.on('uncaughtException', (err: Error) => {
logger.error(`Uncaught Exception: ${err && err.message ? err.message : ''}`);
logger.error(err && err.name ? err.name : '');
logger.error(err && err.stack ? err.stack : '');
// Catch all, incase we have string exceptions being raised.
logger.error(err ? err.toString() : '');
// Wait for 1 second before we die, we need to ensure errors are written to the log file.
setTimeout(() => process.exit(-1), 100);
});
process.on('uncaughtException', (err: Error) => {
logger.error(`Uncaught Exception: ${err && err.message ? err.message : ''}`);
logger.error(err && err.name ? err.name : '');
logger.error(err && err.stack ? err.stack : '');
// Catch all, incase we have string exceptions being raised.
logger.error(err ? err.toString() : '');
// Wait for 1 second before we die, we need to ensure errors are written to the log file.
setTimeout(() => process.exit(-1), 1000);
});
async function startDebugger() {
logger.init(noop, path.join(EXTENSION_ROOT_DIR, `debug${process.pid}.log`));
const serviceContainer = initializeIoc();
const protocolMessageWriter = serviceContainer.get(IProtocolMessageWriter);
try {
// debugger;
const debugManager = new DebugManager(serviceContainer);
await debugManager.start();
} catch (err) {
const message = `Debugger Error: ${err && err.message ? err.message : err.toString()}`;
const details = [message, err && err.name ? err.name : '', err && err.stack ? err.stack : ''].join(EOL);
logger.error(`${message}${EOL}${details}`);
// Notify the user.
protocolMessageWriter.write(process.stdout, new Event('error', message));
protocolMessageWriter.write(process.stdout, new OutputEvent(`${message}${EOL}${details}`, 'stderr'));
}
}
logger.log(`SourceMaps.getInlineSourceMapContents: Inline sourcemap is malformed. Starts with: ${sourceMapData.substr(0, 200)}`);
return null;
}
const header = sourceMapData.substr(0, firstCommaPos);
const data = sourceMapData.substr(firstCommaPos + 1);
try {
if (header.indexOf(';base64') !== -1) {
const buffer = Buffer.from(data, 'base64');
return buffer.toString();
} else {
// URI encoded.
return decodeURI(data);
}
} catch (e) {
logger.error(`SourceMaps.getInlineSourceMapContents: exception while processing data uri (${e.stack})`);
}
return null;
}
// with a tag like "data:application/json;charset:utf-8;base64,". The data should start after the last comma.
let sourceMapContents: string;
if (mapPath.indexOf('data:application/json') >= 0) {
// Sourcemap is inlined
logger.log(`SourceMaps.getMapForGeneratedPath: Using inlined sourcemap in ${pathToGenerated}`);
sourceMapContents = this.getInlineSourceMapContents(mapPath);
} else {
sourceMapContents = await this.getSourceMapContent(pathToGenerated, mapPath);
}
if (sourceMapContents) {
try {
// Throws for invalid JSON
return SourceMap.create(pathToGenerated, sourceMapContents, this._pathMapping, this._sourceMapPathOverrides);
} catch (e) {
logger.error(`SourceMaps.getMapForGeneratedPath: exception while processing path: ${pathToGenerated}, sourcemap: ${mapPath}\n${e.stack}`);
return null;
}
} else {
return null;
}
}
return null;
}
const header = this.customerContentData.substr(0, firstCommaPos);
const data = this.customerContentData.substr(firstCommaPos + 1);
try {
if (header.indexOf(';base64') !== -1) {
const buffer = new Buffer(data, 'base64');
return new SourceMapContents(buffer.toString());
} else {
// URI encoded.
return new SourceMapContents(decodeURI(data));
}
} catch (e) {
logger.error(`SourceMaps.getInlineSourceMapContents: exception while processing data uri (${e.stack})`);
}
return null;
}
.catch(ex => {
logger.error('Attach failed');
logger.error(`${ex}, ${ex.name}, ${ex.message}, ${ex.stack}`);
const message = this.getUserFriendlyAttachErrorMessage(ex) || 'Attach Failed';
this.sendErrorResponse(response, { format: message, id: 1 }, undefined, undefined, ErrorDestination.User);
});
this._inFlightRequests.then(() => this._eventsToClientReporter.sendBPStatusChanged({ reason: 'changed', bpRecipeStatus: statusChanged.status }), rejection => {
logger.error(`Failed to send a breakpoint status update: ${rejection}`);
});
}