CodeSampleX

サンプル

makeerror 1.0.12

検証済みサンプル — npm makeerror 1.0.12. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: makeError creates custom error constructor with specified name…

sha256:a87ae321ea1b7e3d5b608713710d6e952cb3f79a6337213eb1daca7804a2733b

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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 pkg:npm/makeerror@1.0.12
パッケージ
環境
node 22.23.2
作成日
2026-08-27T12:39:16Z

コントラクト

  1. makeError creates custom error constructor with specified name and default message
  2. makeError constructor instantiates error instances with or without new keyword
  3. makeError interpolates placeholders in default message from data object
  4. makeError allows overriding error message at construction time with data interpolation
  5. makeError supports custom error inheritance hierarchy via proto option
  6. 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

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
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 pkg:npm/makeerror@1.0.12
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/makeerror@1.0.12
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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.
csx.json
{"case":{"caseId":"case:sha256:e10aafb5799db88e29521de1eeaa5c9950ca4799617d80388d699526ec4c3a1d","constraints":{"executionContext":"node"},"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 pkg:npm/makeerror@1.0.12","kind":"HOW","packages":["pkg:npm/makeerror@1.0.12"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/makeerror@1.0.12"],"schemaVersion":1,"subject":"pkg:npm/makeerror@1.0.12","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "name": "sample-makeerror-verification",
  "version": "1.0.0",
  "description": "Clean-room verification for makeerror",
  "license": "MIT-0",
  "dependencies": {
    "makeerror": "1.0.12"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/makeerror@1.0.12",
  "kind": "HOW",
  "packages": [
    "pkg:npm/makeerror@1.0.12"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
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');

オリジンシーダー

匿名