price handling
This commit is contained in:
@@ -26,6 +26,19 @@ const headers = {
|
||||
Accept: 'application/json'
|
||||
}
|
||||
|
||||
function formatApiErrorMessage(raw: string): string {
|
||||
const unknownColumn = raw.match(/Unknown column '([^']+)'/)
|
||||
if (unknownColumn) {
|
||||
return `ستون «${unknownColumn[1]}» در دیتابیس وجود ندارد — سرور را بهروز کنید یا با پشتیبانی تماس بگیرید`
|
||||
}
|
||||
|
||||
if (raw.length > 220) {
|
||||
return `${raw.slice(0, 220)}…`
|
||||
}
|
||||
|
||||
return raw
|
||||
}
|
||||
|
||||
const _axios = axios.create({
|
||||
baseURL,
|
||||
headers
|
||||
@@ -82,7 +95,12 @@ _axios.interceptors.response.use(
|
||||
}
|
||||
} else if (error.response) {
|
||||
if (!error.config?.meta?.silent) {
|
||||
message.error('خطا در بارگذاری اطلاعات')
|
||||
const apiMessage = error.response.data?.message
|
||||
message.error(
|
||||
typeof apiMessage === 'string' && apiMessage.trim()
|
||||
? formatApiErrorMessage(apiMessage)
|
||||
: 'خطا در بارگذاری اطلاعات',
|
||||
)
|
||||
}
|
||||
}
|
||||
// Any status codes that falls outside the range of 2xx cause this function to trigger
|
||||
|
||||
Reference in New Issue
Block a user