19 lines
589 B
JavaScript
19 lines
589 B
JavaScript
export const isWriteOutcomeUnknown = (error) => {
|
|
if (!error || typeof error !== 'object') return false
|
|
if (
|
|
error.code === 'REQUEST_TIMEOUT' ||
|
|
error.code === 'NETWORK_ERROR' ||
|
|
error.code === 'RESPONSE_INVALID' ||
|
|
error.code === 'REQUEST_CANCELLED'
|
|
) {
|
|
return true
|
|
}
|
|
if (error.code !== 'HTTP_ERROR' && error.code !== 'BUSINESS_ERROR') return false
|
|
|
|
const status = Number(
|
|
error.code === 'HTTP_ERROR' ? error.httpStatus : error.businessCode
|
|
)
|
|
if (!Number.isInteger(status)) return true
|
|
return !(status >= 400 && status < 500 && status !== 408)
|
|
}
|