Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

GochoMugo/happy-waterline-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️⚠️⚠️ This repo has been archived. I no longer use waterline framework. ⚠️⚠️⚠️

happy-waterline-errors

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! 🚧

node npm Travis Gemnasium Coveralls

usage:

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);
  })

API:

import happy from "happy-waterline-errors";

happy(error [, options])

Formats waterline error. You can provide options.

  • options (Object):
    • key (Function): function may be used to format attribute keys

errors:

validation errors:

{
  code: "err_validation",
  status: 422,
  message: "validation failed",
  description: [
    {
      field: "email",
      rules: [
        "email",
      ],
    },
    {
      field: "lastName",
      rules: [
        "required",
        "string",
      ],
    },
  ],
}

unknown errors:

{
  code: "err_unknown",
  status: 500,
  message: "unknown error",
}

forbidden errors:

{
  code: "err_forbidden",
  status: 403,
  message: "action is forbidden",
}

license:

The MIT License (MIT)

Copyright (c) 2015 GochoMugo mugo@forfuture.co.ke

About

i want to be happy handling waterline errors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published