JSPM

  • Created
  • Published
  • Downloads 2183873
  • Score
    100M100P100Q172834F

Custom errors

Package Exports

  • error/validation

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (error) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

  • Raynos

MIT Licenced