node/test/parallel/test-permission-wasi.js
Rafael Gonzaga 24e4a54471
src,permission: make ERR_ACCESS_DENIED more descriptive
This commit also adds a suggestion flag (if exists)
when ERR_ACCESS_DENIED is thrown, so users don't need
to jump into the documentation to see how to manage
that permission error.

PR-URL: https://github.com/nodejs/node/pull/57585
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-04-03 22:24:39 +00:00

21 lines
461 B
JavaScript

// Flags: --permission --allow-fs-read=*
'use strict';
const common = require('../common');
const assert = require('node:assert');
const { WASI } = require('wasi');
{
assert.throws(() => {
new WASI({
version: 'preview1',
preopens: { '/': '/' },
});
}, common.expectsError({
message: 'Access to this API has been restricted. Use --allow-wasi to manage permissions.',
code: 'ERR_ACCESS_DENIED',
permission: 'WASI',
}));
}