Skip to content

Instantly share code, notes, and snippets.

@phanect
Last active May 12, 2024 03:15
Show Gist options
  • Save phanect/d2548106b1c6cbb6142eb07c0a87829d to your computer and use it in GitHub Desktop.
Save phanect/d2548106b1c6cbb6142eb07c0a87829d to your computer and use it in GitHub Desktop.
Experiment if error stops the Node.js process as a failure. (Tested on Node.js v22.1.0)
const { fn } = require("./async-err-lib.cjs");
(async () => {
await fn();
})();
import { fn } from "./async-err-lib.js";
await fn(); // Error is shown as expected.
module.exports.fn = async () => {
throw new Error("By this error, the process would fail.");
};
export const fn = async () => {
throw new Error("By this error, the process would fail.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment