Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@fabrix/spool-errors

fabrix-app5MIT1.6.2TypeScript support: included

Spool: Standard Errors for Fabrix as a spool

html, joi, errors, spool, fabrix, trailjs

readme

spool-errors

Gitter NPM version Build Status Test Coverage Dependency Status Follow @FabrixApp on Twitter

:package: Errors Spool

A Spool to extend Fabrix with Standard Errors

Install

$ npm install --save @fabrix/spool-errors

Configure

// config/main.ts
import { ErrorsSpool } from '@fabrix/spool-errors'
export const main = {
  spools: [
    // ... other spools
    ErrorsSpool
  ]
}

Configuration

You can easily extend the generic errors

// config/errors.ts
import { GenericError } from '@fabrix/spool-error/errors'
export const errors = {
  TestError: class TestError extends GenericError {}
}

Usage

Use spool-errors to standardize Joi errors

const schema = Joi.object({
      username: Joi.string()
        .alphanum()
        .min(3)
        .max(30)
        .required(),
      })


const test = schema.validate({})

const { value, error } = this.app.transformJoiError(test, TestError)

if (error) {
  assert(error instanceof TestError)
  throw error
}
else {
  // do something with value
}

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.6.2 (2019-10-21)

Bug Fixes

  • fixes extension to better name (198d875)
  • returns integers instead of strings (573ff37)

Features

  • allows using custom errors in config (9297051)
  • init commit :fire: (eadb126)