CodeSampleX

샘플

error-ex 1.3.4

검증된 샘플 — npm error-ex 1.3.4. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: errorEx creates a custom Error subclass that can be instantiated…

sha256:cc4fa472e89afc27116cb0e54c50a90e02190325b99610c48ed94bcdfd202f61

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-23

케이스

HOW
목표
verify pkg:npm/error-ex@1.3.4
패키지
생성일
2026-08-23T15:41:58Z

컨트랙트

  1. errorEx creates a custom Error subclass that can be instantiated with or without new
  2. errorEx unwraps message when instantiated with an existing Error instance
  3. errorEx defaults error name to Error when name parameter is omitted or not a string
  4. errorEx.append modifier appends formatted property values to error message
  5. errorEx.line modifier inserts custom formatted line into error stack trace
  6. errorEx instances support message setter and stack setter override

파일

  • 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/error-ex@1.3.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/error-ex@1.3.4

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:42dabfce4ae6e58ec0d6e2f02e690f3dcb25b2acc975f9852e10ba7ec0af35f4","contract":["errorEx creates a custom Error subclass that can be instantiated with or without new","errorEx unwraps message when instantiated with an existing Error instance","errorEx defaults error name to Error when name parameter is omitted or not a string","errorEx.append modifier appends formatted property values to error message","errorEx.line modifier inserts custom formatted line into error stack trace","errorEx instances support message setter and stack setter override"],"goal":"verify pkg:npm/error-ex@1.3.4","kind":"HOW","packages":["pkg:npm/error-ex@1.3.4"],"schemaVersion":1},"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/error-ex@1.3.4"],"schemaVersion":1,"subject":"pkg:npm/error-ex@1.3.4","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-error-ex",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-error-ex",
      "version": "1.0.0",
      "dependencies": {
        "error-ex": "1.3.4"
      }
    },
    "node_modules/error-ex": {
      "version": "1.3.4",
      "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz",
      "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==",
      "license": "MIT",
      "dependencies": {
        "is-arrayish": "^0.2.1"
      }
    },
    "node_modules/is-arrayish": {
      "version": "0.2.1",
      "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
      "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-error-ex",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "error-ex": "1.3.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/error-ex@1.3.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/error-ex@1.3.4"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import errorEx from 'error-ex';

// 1. errorEx creates a custom Error subclass that can be instantiated with or without new
{
  const CustomError = errorEx('CustomError');
  const errWithNew = new CustomError('something failed');
  const errWithoutNew = CustomError('call without new');

  assert.ok(errWithNew instanceof Error);
  assert.ok(errWithNew instanceof CustomError);
  assert.equal(errWithNew.name, 'CustomError');
  assert.equal(errWithNew.message, 'something failed');
  assert.ok(errWithNew.stack.includes('CustomError: something failed'));

  assert.ok(errWithoutNew instanceof Error);
  assert.ok(errWithoutNew instanceof CustomError);
  assert.equal(errWithoutNew.name, 'CustomError');
  assert.equal(errWithoutNew.message, 'call without new');
}

// 2. errorEx unwraps message when instantiated with an existing Error instance
{
  const CustomError = errorEx('CustomError');
  const original = new Error('original message');
  const wrapped = new CustomError(original);

  assert.equal(wrapped.message, 'original message');
  assert.ok(wrapped instanceof CustomError);
  assert.ok(wrapped instanceof Error);
}

// 3. errorEx defaults error name to Error when name parameter is omitted or not a string
{
  const DefaultError = errorEx();
  const err = new DefaultError('default name test');

  assert.equal(err.name, 'Error');
  assert.equal(err.message, 'default name test');
  assert.ok(err instanceof Error);
}

// 4. errorEx.append modifier appends formatted property values to error message
{
  const JSONError = errorEx('JSONError', {
    fileName: errorEx.append('in %s'),
  });

  const err = new JSONError('Unexpected token');
  assert.equal(err.message, 'Unexpected token');

  err.fileName = 'package.json';
  assert.equal(err.message, 'Unexpected token in package.json');
}

// 5. errorEx.line modifier inserts custom formatted line into error stack trace
{
  const FileError = errorEx('FileError', {
    location: errorEx.line('at %s'),
  });

  const err = new FileError('read error');
  err.location = 'line 42, column 5';

  const stack = err.stack;
  const stackLines = stack.split('\n');
  assert.equal(stackLines[0], 'FileError: read error');
  assert.equal(stackLines[1], '    at line 42, column 5');
}

// 6. errorEx instances support message setter and stack setter override
{
  const CustomError = errorEx('CustomError');
  const err = new CustomError('initial message');

  err.message = 'updated message';
  assert.equal(err.message, 'updated message');

  err.stack = 'CustomError: manual stack\n    at test';
  assert.equal(err.stack, 'CustomError: manual stack\n    at test');
}

오리진 시더

익명