mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 07:30:16 +03:00
feat: add example
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { {{name.pascalCase}}RestApiTransportError } from '../errors'
|
||||
|
||||
/**
|
||||
* Выполняет fetch с явной классификацией transport failure.
|
||||
*/
|
||||
export const {{name.camelCase}}RestApiFetch: typeof fetch = async (...params) => {
|
||||
try {
|
||||
return await fetch(...params)
|
||||
} catch (error) {
|
||||
const code = error instanceof DOMException && error.name === 'AbortError' ? 'REQUEST_TIMEOUT' : 'NETWORK_UNAVAILABLE'
|
||||
|
||||
throw new {{name.pascalCase}}RestApiTransportError(code, error)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user