Treat Tahesab 404 no-records as empty asnad list.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -97,11 +97,23 @@ export class TahesabHttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const status = res.statusCode ?? 0;
|
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 (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(
|
this.logger.warn(
|
||||||
`Tahesab ${method} ${path} → ${status}: ${text.slice(0, 400)}`,
|
`Tahesab ${method} ${path} → ${status}: ${text.slice(0, 400)}`,
|
||||||
);
|
);
|
||||||
const detail = extractTahesabError(json, text);
|
|
||||||
reject(
|
reject(
|
||||||
new BadGatewayException(
|
new BadGatewayException(
|
||||||
detail
|
detail
|
||||||
@@ -113,12 +125,7 @@ export class TahesabHttpClient {
|
|||||||
}
|
}
|
||||||
// بعضی متدها با ۲۰۰ و فیلد ERROR برمیگردند
|
// بعضی متدها با ۲۰۰ و فیلد ERROR برمیگردند
|
||||||
if (json && typeof json === 'object' && 'ERROR' in (json as object)) {
|
if (json && typeof json === 'object' && 'ERROR' in (json as object)) {
|
||||||
const detail = extractTahesabError(json, text);
|
if (isEmptyOk) {
|
||||||
if (
|
|
||||||
detail &&
|
|
||||||
opts.emptyResultOnError &&
|
|
||||||
opts.emptyResultOnError.test(detail)
|
|
||||||
) {
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Tahesab ${path} empty-on-error: ${detail.slice(0, 120)}`,
|
`Tahesab ${path} empty-on-error: ${detail.slice(0, 120)}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -579,7 +579,9 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="!asnadLoading && !asnadItems.length" class="muted">سندی نیست.</p>
|
<p v-if="!asnadLoading && !asnadItems.length" class="muted">
|
||||||
|
در این بازه سندی یافت نشد.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form v-show="activeTab === 'ثبت سند'" class="sanad-form card" @submit.prevent="pushSanad">
|
<form v-show="activeTab === 'ثبت سند'" class="sanad-form card" @submit.prevent="pushSanad">
|
||||||
|
|||||||
Reference in New Issue
Block a user