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 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)}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user