示例
makeerror 1.0.12: makeerror
已验证示例 — npm makeerror 1.0.12: makeerror. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: makeError creates custom error constructor with specified…
sha256:8ace1f03e5108f7ede9c558647fa8b1d22275201ba521e7e78dc49fe150f1c9b
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
案例
HOW- 目标
- verify makeerror in pkg:npm/makeerror@1.0.12
- 符号
-
- makeerror
- 创建时间
- 2026-08-27T18:49:46Z
契约
- makeError creates custom error constructor with specified name and default message
- makeError constructor instantiates error instances with or without new keyword
- makeError interpolates placeholders in default message from data object
- makeError allows overriding error message at construction time with data interpolation
- makeError supports custom error inheritance hierarchy via proto option
- makeError rejects invalid proto that is not derived from makeError BaseError
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
源代码
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify makeerror in pkg:npm/makeerror@1.0.12
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/makeerror@1.0.12
Demonstrate these symbols/APIs:
- makeerror
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:55f12af7b0744f8550ff1d13b915bb4d0a4ffe83599aaf6996842a9f09d3954b","contract":["makeError creates custom error constructor with specified name and default message","makeError constructor instantiates error instances with or without new keyword","makeError interpolates placeholders in default message from data object","makeError allows overriding error message at construction time with data interpolation","makeError supports custom error inheritance hierarchy via proto option","makeError rejects invalid proto that is not derived from makeError BaseError"],"goal":"verify makeerror in pkg:npm/makeerror@1.0.12","kind":"HOW","packages":["pkg:npm/makeerror@1.0.12"],"schemaVersion":1,"symbols":["makeerror"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/makeerror@1.0.12"],"schemaVersion":1,"subject":"pkg:npm/makeerror@1.0.12","symbols":["makeerror"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-makeerror-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-makeerror-verification",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"makeerror": "1.0.12"
}
},
"node_modules/makeerror": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz",
"integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==",
"license": "BSD-3-Clause",
"dependencies": {
"tmpl": "1.0.5"
}
},
"node_modules/tmpl": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
"integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==",
"license": "BSD-3-Clause"
}
}
}
{
"name": "sample-makeerror-verification",
"version": "1.0.0",
"description": "Clean-room verification for makeerror",
"license": "MIT-0",
"dependencies": {
"makeerror": "1.0.12"
}
}
{
"schemaVersion": 1,
"goal": "verify makeerror in pkg:npm/makeerror@1.0.12",
"kind": "HOW",
"packages": [
"pkg:npm/makeerror@1.0.12"
],
"symbols": [
"makeerror"
]
}
import assert from 'node:assert';
import makeError from 'makeerror';
// 1. makeError creates custom error constructor with specified name and default message
const CustomError = makeError('CustomError', 'default error message');
const err1 = CustomError();
assert.ok(err1 instanceof Error);
assert.ok(err1 instanceof CustomError);
assert.strictEqual(err1.name, 'CustomError');
assert.strictEqual(err1.message, 'default error message');
// 2. makeError constructor instantiates error instances with or without new keyword
const errWithoutNew = CustomError('message without new');
const errWithNew = new CustomError('message with new');
assert.ok(errWithoutNew instanceof CustomError);
assert.ok(errWithNew instanceof CustomError);
assert.strictEqual(errWithoutNew.message, 'message without new');
assert.strictEqual(errWithNew.message, 'message with new');
// 3. makeError interpolates placeholders in default message from data object
const TemplateError = makeError('TemplateError', 'User {id} failed on {action}');
const templatedErr = TemplateError({ id: '42', action: 'checkout' });
assert.strictEqual(templatedErr.message, 'User 42 failed on checkout');
assert.strictEqual(templatedErr.data.id, '42');
assert.strictEqual(templatedErr.data.action, 'checkout');
// 4. makeError allows overriding error message at construction time with data interpolation
const OverriddenError = makeError('OverriddenError', 'default');
const customMsgErr = OverriddenError('Resource {item} status: {code}', { item: 'cart', code: 'timeout' });
assert.strictEqual(customMsgErr.message, 'Resource cart status: timeout');
assert.strictEqual(customMsgErr.data.item, 'cart');
assert.strictEqual(customMsgErr.data.code, 'timeout');
// 5. makeError supports custom error inheritance hierarchy via proto option
const ParentError = makeError('ParentError', 'parent failure');
const ChildError = makeError('ChildError', 'child failure', { proto: new ParentError() });
const childErr = ChildError('child instance');
assert.ok(childErr instanceof ChildError);
assert.ok(childErr instanceof ParentError);
assert.ok(childErr instanceof Error);
assert.strictEqual(childErr.name, 'ChildError');
assert.strictEqual(childErr.message, 'child instance');
// 6. makeError rejects invalid proto that is not derived from makeError BaseError
assert.throws(
() => makeError('InvalidError', 'msg', { proto: new Error('raw error') }),
/The custom "proto" must be an Error created via makeError/
);
console.log('Contract passed');
原始种子者
匿名