Common Library from Gits Indonesia. Purpose to implement reusable code.
- throw Error for HTTP
try{
throw new ErrorHTTP(400, "Bad request");
}catch (error){
console.error(error)
}
try{
throw new ErrorHTTPBadRequest("Validation Error");
}catch (error){
console.error(error)
}
Other error exception can be used:
- ErrorHTTPUnauthorized
- ErrorHTTPForbidden
- ErrorHTTPNotFound
- ErrorHTTPServerError
- ErrorHTTPBadGateway