GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dancastillo/error: A small utility for generating consistent errors

BranchesTags
Open more actions menu

Latest commit

 

History

29 Commits
29 Commits

Folders and files

NameName
Last commit message
Last commit date
.changeset
.changeset
 
 
.github
.github
 
 
.husky
.husky
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.prettierrc
.prettierrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
eslint.config.mjs
eslint.config.mjs
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.test.json
tsconfig.test.json
 
 
tsup.config.ts
tsup.config.ts
 
 

Repository files navigation

@dancastillo/error

A small utility for generating consistent errors

Install

npm

npm install @dancastillo/error

yarn

npm add @dancastillo/error

pnpm

pnpm install @dancastillo/error

Usage

createError(code, message [, detail [, meta]])
  • code (number, required) - The error code, you can access it viaerror.code.
  • message (string, required) - The error message.
  • detail (string[], optional) - The error detail. You can include additional information about the error that has occurred.
  • meta (T extends object, optional) - Additional metadata object that you can pass in with generic.

TypeScript Example

import { createError, type DCError } from '@dancastillo/error'

type Meta = { userId: string }

const err = createError<Meta>(500, 'Title', 'Detail', { userId: 'some-user-id' })

console.log(err.code) // 500
console.log(err.title) // 'Title'
console.log(err.detail) // 'Detail'
console.log(err.meta) // { userId: 'some-user-id' }

JavaScript Example

import { createError } from '@dancastillo/error'

const err = createError(500, 'Title', 'Detail', { userId: 'some-user-id' })

console.log(err.code) // 500
console.log(err.title) // 'Title'
console.log(err.detail) // 'Detail'
console.log(err.meta) // { userId: 'some-user-id' }

License

Licensed under MIT.

About

A small utility for generating consistent errors

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.