@fatcherjs/middleware-exception
January 10, 2026 ยท View on GitHub
Install
NPM
>$ npm install @fatcherjs/middleware-exception
CDN
<script src="https://cdn.jsdelivr.net/npm/fatcher/dist/fatcher.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@fatcherjs/middleware-exception/dist/index.min.js"></script>
<script>
Fatcher.fatcher('url', {
middlewares: [FatcherMiddlewareException],
})
.then(response => {
console.log(response);
})
.catch(err => {
if (FatcherMiddlewareException.isFatcherError(err)) {
// http error
return;
}
// other
});
</script>
Usage
import { fatcher } from 'fatcher';
import { isFatcherError, exception } from '@fatcherjs/middleware-exception';
fatcher('https://foo.bar', { middlewares: [exception] }).catch(error => {
if (isFatcherError(error)) {
// handle fatcher error
return;
}
// handle other error
});
options
validateCode
import { fatcher } from 'fatcher';
import { isFatcherError, exception } from '@fatcherjs/middleware-exception';
fatcher('https://foo.bar', {
middlewares: [exception],
// throw FatcherError when status is not 200
validateCode: status => status === 200,
}).catch(error => {
if (isFatcherError(error)) {
// handle fatcher error
return;
}
// handle other error
});