Unify Harbor error handling across server and client
All checks were successful
Build and Deploy Gateway / build-and-push (push) Successful in 15s
Build and Deploy Gateway / deploy (push) Successful in 12s

This commit is contained in:
2026-07-11 20:38:41 +03:00
parent 457dd912d1
commit 9da4fef1f0
16 changed files with 493 additions and 100 deletions

View File

@@ -0,0 +1,28 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
ERROR_DEFINITIONS,
HarborError,
normalizeHarborError,
} from '../../src/shared/errors.js';
test('every Harbor error code has stable Russian copy and retry policy', () => {
for (const [code, definition] of Object.entries(ERROR_DEFINITIONS)) {
const error = new HarborError(code);
assert.equal(error.code, code);
assert.equal(error.message, definition.message);
assert.equal(error.retryable, definition.retryable);
assert.match(error.message, /[А-Яа-яЁё]/);
assert.equal(typeof error.status, 'number');
}
});
test('unknown failures use the safe non-retryable fallback', () => {
const error = normalizeHarborError(new Error('secret internal failure'));
assert.equal(error.code, 'UNKNOWN');
assert.equal(error.message, ERROR_DEFINITIONS.UNKNOWN.message);
assert.equal(error.retryable, false);
assert.equal(error.message.includes('secret'), false);
});