Closed froderis closed 3 years ago
Currently most of the cases listed are covered except the redirect case. Whenever throwable is triggered, a Boom error is created and the http status code is attached: https://github.com/podium-lib/client/blob/master/lib/resolver.content.js#L152-L159
podlet marked as throwable gets status code on error.output property
try {
const result = podlet.fetch(incoming);
} catch (error) {
// do something with error
// error.output.statusCode === 404
// send error to express error middleware with...
next(error)
}
All non 2xx responses will trigger the catch block and its then up to you how you want to handle.
The one case we don't have fully covered is the redirect case because we currently do not attach the location
header to the error so while you can check that the status code is 3xx, you can't actually do anything about this. We will add this.
Working on this here: https://github.com/podium-lib/client/pull/104
Fixed in podium-lib/client#104
Some cases requires a podlet to send redirects or set the page status code. The current need is a CMS podlet that keeps track of changed urls and sends permanent redirect. Other use cases are triggering a login flow or setting 404 or 410 for cms or ad content.