⚠️ ⚠️ ⚠️ This repo has been archived. I no longer use waterline framework.⚠️ ⚠️ ⚠️
i want to be happy handling waterline errors
🚧 It is a bad idea to use this module! I made it to lessen my work! And it is not yet comprehensive! 🚧
import happy from "happy-waterline-errors";
// formats errors from Waterline to make them more user-friendly
// you can even send it back to your users as response! I do that!
User
.create({ firstName: "gocho" })
.exec(function(error, user) {
if (error) {
return console.log("user-friendly error: %j", happy(error));
}
return console.log("user: %j", error);
})
import happy from "happy-waterline-errors";
Formats waterline error
. You can provide options
.
options
(Object):key
(Function): function may be used to format attribute keys
{
code: "err_validation",
status: 422,
message: "validation failed",
description: [
{
field: "email",
rules: [
"email",
],
},
{
field: "lastName",
rules: [
"required",
"string",
],
},
],
}
{
code: "err_unknown",
status: 500,
message: "unknown error",
}
{
code: "err_forbidden",
status: 403,
message: "action is forbidden",
}
The MIT License (MIT)
Copyright (c) 2015 GochoMugo mugo@forfuture.co.ke