error
Custom errors
Example
var ValidationError = require("error/validation")
var OptionError = require("error/option")
var error = ValidationError([{
message: "Please enter required field",
attribute: "name"
}, {
message: "Password must be at least 10 characters",
attribute: "password"
}])
console.log("error.errors", error.errors)
var error = OptionError("Something went wrong", metaData)
console.log("error.option", error.option)
Docs
type OptionError<T> := {
option?: T,
message: String,
type: "OptionError"
}
type ValidationError := {
errors: Array<Error>,
message: String,
type: "ValidationError"
}
error/option := (String, T) => OptionError<T>
error/validation := (Array<Error>) => ValidationError
Installation
npm install error
Contributors
MIT Licenced