GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: allow fatal exceptions to be enhanced · jaku/node@36fdf1a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_errors.cc
  • test/parallel
    • test-unhandled-exception-rethrow-error.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_errors.cc‎

Copy file name to clipboardExpand all lines: src/node_errors.cc
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,11 @@ TryCatchScope::~TryCatchScope() {
448448
HandleScope scope(env_->isolate());
449449
Local<v8::Value> exception = Exception();
450450
Local<v8::Message> message = Message();
451+
EnhanceFatalException enhance = CanContinue() ?
452+
EnhanceFatalException::kEnhance : EnhanceFatalException::kDontEnhance;
451453
if (message.IsEmpty())
452454
message = Exception::CreateMessage(env_->isolate(), exception);
453-
ReportFatalException(
454-
env_, exception, message, EnhanceFatalException::kDontEnhance);
455+
ReportFatalException(env_, exception, message, enhance);
455456
env_->Exit(7);
456457
}
457458
}
Collapse file

‎test/parallel/test-unhandled-exception-rethrow-error.js‎

Copy file name to clipboard
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
require('../common');
3+
4+
if (process.argv[2] === 'child') {
5+
process.on('uncaughtException', (err) => {
6+
err.rethrow = true;
7+
throw err;
8+
});
9+
10+
function throwException() {
11+
throw new Error('boom');
12+
}
13+
14+
throwException();
15+
} else {
16+
const assert = require('assert');
17+
const { spawnSync } = require('child_process');
18+
const result = spawnSync(process.execPath, [__filename, 'child']);
19+
20+
assert.strictEqual(result.status, 7);
21+
assert.strictEqual(result.signal, null);
22+
assert.strictEqual(result.stdout.toString().trim(), '');
23+
// Verify that the error was thrown and that the stack was preserved.
24+
const stderr = result.stderr.toString();
25+
assert(/Error: boom/.test(stderr));
26+
assert(/at throwException/.test(stderr));
27+
assert(/rethrow: true/.test(stderr));
28+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.