MCPcopy Index your code
hub / github.com/nodejs/node / checkOperationError

Function checkOperationError

test/parallel/test-fs-promises-file-handle-op-errors.js:30–51  ·  view source on GitHub ↗
(op)

Source from the content-addressed store, hash-verified

28}
29
30async function checkOperationError(op) {
31 try {
32 const filePath = await createFile();
33 Object.defineProperty(FileHandle.prototype, 'fd', {
34 get: common.mustCall(function() {
35 // Verify that close is called when an error is thrown
36 this.close = common.mustCall(this.close);
37 const opError = new Error('INTERNAL_ERROR');
38 opError.code = 123;
39 throw opError;
40 }),
41 });
42
43 await assert.rejects(op(filePath), {
44 name: 'Error',
45 message: 'INTERNAL_ERROR',
46 code: 123,
47 });
48 } finally {
49 Object.defineProperty(FileHandle.prototype, 'fd', originalFd);
50 }
51}
52(async function() {
53 tmpdir.refresh();
54 await checkOperationError((filePath) => truncate(filePath));

Calls 3

createFileFunction · 0.70
opFunction · 0.50
definePropertyMethod · 0.45

Tested by

no test coverage detected