Treat Tahesab 404 no-records as empty asnad list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-05 11:35:20 +03:30
co-authored by Cursor
parent 8f9a00f319
commit 11fa4c5e23
2 changed files with 17 additions and 8 deletions
@@ -97,11 +97,23 @@ export class TahesabHttpClient {
}
}
const status = res.statusCode ?? 0;
const detail = extractTahesabError(json, text);
const isEmptyOk =
Boolean(detail) &&
Boolean(opts.emptyResultOnError) &&
opts.emptyResultOnError!.test(detail);
if (status < 200 || status >= 300) {
if (isEmptyOk) {
this.logger.debug(
`Tahesab ${path} ${status} empty-on-error: ${detail.slice(0, 120)}`,
);
resolve([] as T);
return;
}
this.logger.warn(
`Tahesab ${method} ${path} → ${status}: ${text.slice(0, 400)}`,
);
const detail = extractTahesabError(json, text);
reject(
new BadGatewayException(
detail
@@ -113,12 +125,7 @@ export class TahesabHttpClient {
}
// بعضی متدها با ۲۰۰ و فیلد ERROR برمی‌گردند
if (json && typeof json === 'object' && 'ERROR' in (json as object)) {
const detail = extractTahesabError(json, text);
if (
detail &&
opts.emptyResultOnError &&
opts.emptyResultOnError.test(detail)
) {
if (isEmptyOk) {
this.logger.debug(
`Tahesab ${path} empty-on-error: ${detail.slice(0, 120)}`,
);
@@ -579,7 +579,9 @@ onMounted(async () => {
</div>
</article>
</div>
<p v-if="!asnadLoading && !asnadItems.length" class="muted">سندی نیست.</p>
<p v-if="!asnadLoading && !asnadItems.length" class="muted">
در این بازه سندی یافت نشد.
</p>
</div>
<form v-show="activeTab === 'ثبت سند'" class="sanad-form card" @submit.prevent="pushSanad">