fix: replace throw error with axios error handling in SalesOrderService and MarketingExportService

All catch blocks in singleApproval, bulkApprovals (both classes), and
delivery now return error.response?.data for axios errors and undefined
otherwise, consistent with the BaseApiService pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ValdiANS
2026-06-03 14:20:43 +07:00
parent 97acc17ca5
commit f167916a21
+20 -8
View File
@@ -45,8 +45,11 @@ export class SalesOrderService extends BaseApiService<
notes: notes || `${action} marketing ${id}`, notes: notes || `${action} marketing ${id}`,
}, },
}); });
} catch (error) { } catch (error: unknown) {
throw error; if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
return error.response?.data;
}
return undefined;
} }
} }
@@ -68,8 +71,11 @@ export class SalesOrderService extends BaseApiService<
notes: notes || `${action} marketing ${ids.join(', ')}`, notes: notes || `${action} marketing ${ids.join(', ')}`,
}, },
}); });
} catch (error) { } catch (error: unknown) {
throw error; if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
return error.response?.data;
}
return undefined;
} }
} }
@@ -110,8 +116,11 @@ export class SalesOrderService extends BaseApiService<
notes: notes || `Delivery marketing ${id}`, notes: notes || `Delivery marketing ${id}`,
}, },
}); });
} catch (error) { } catch (error: unknown) {
throw error; if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
return error.response?.data;
}
return undefined;
} }
} }
} }
@@ -142,8 +151,11 @@ class MarketingExportService extends BaseApiService<
notes: notes, notes: notes,
}, },
}); });
} catch (error) { } catch (error: unknown) {
throw error; if (axios.isAxiosError<BaseApiResponse<Marketing[] | Marketing>>(error)) {
return error.response?.data;
}
return undefined;
} }
} }