fix(registries): 계약 조립 실패의 원인을 check:registries에 한 번만 찍는다
문제: 계약 조립이 실패하면 check:registries 출력에 같은 원인이 두 번 나온다. 1103/09-07 수정이 ContractContributionError의 message 끝에 reason을 붙였고, 1103/14-06 수정이 loadErrorText에서 message 뒤에 "(reason: ...)"를 또 붙였다. 두 수정이 다른 브랜치에서 들어왔다. 기존 테스트는 reason이 message에 없는 가짜 오류로만 시험해 중복을 보지 못했다. 고른 방법: loadErrorText가 message에 reason이 이미 들어 있으면 붙이지 않는다. reason을 message에 싣지 않는 오류(기존 테스트의 가짜 오류)는 지금처럼 "(reason: ...)"가 붙는다. 버린 대안: ContractContributionError message에서 reason을 다시 빼는 것. message만 찍는 다른 출구(부팅 오류, 테스트 출력)가 원인을 잃는다(1103/09-07이 고친 문제). 위험·한계: message 첫 줄만 보므로 여러 줄 reason은 다시 붙는다. 지금 reason은 한 줄이다. docs/manual/reference/errors.md의 출력 형식 줄을 실제 출력에 맞췄다. 검증: desktop batch에서 확인. node scripts/run-vitest.ts run tests/unit/registry-governance.test.ts 새 테스트는 실제 ContractContributionError를 던지는 source로 check:registries를 돌려 원인이 한 번만 나오는지 본다. Refs: 1105/09-03
This commit is contained in:
@@ -152,13 +152,17 @@ async function resolveRegistrySource(
|
||||
}
|
||||
|
||||
/**
|
||||
* 1103/14-06. A contract composition failure (`ContractContributionError`)
|
||||
* says only "not composable"; its cause is the `reason` property.
|
||||
* 1103/14-06. A load error's cause may be only in its `reason` property, so
|
||||
* it is printed after the message. 1105/09-03. `ContractContributionError`
|
||||
* already ends its message with the reason (1103/09-07); that cause is
|
||||
* printed once.
|
||||
*/
|
||||
function loadErrorText(error: Error): string {
|
||||
const message = error.message.split("\n")[0] ?? "";
|
||||
const reason: unknown = (error as Error & { reason?: unknown }).reason;
|
||||
return typeof reason === "string" && reason.length > 0
|
||||
return typeof reason === "string" &&
|
||||
reason.length > 0 &&
|
||||
!message.includes(reason)
|
||||
? `${message} (reason: ${reason})`
|
||||
: message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user