Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
simplify your project error handling & conveying issues to outside world
This is a completely free public domain software, read more in the end
statusCode
to return from your error code ; no more guessing / writing deep logic for exact statusCode
to sendconst errorObj = {
404 : {
"userNotFound": "userNotFound",
"orgNotFound": "orgNotFound"
},
500 : {
"unknown: "unknown"
}
}
const errorKey = require("error-key");
errorKey.initErrors([], errorObj) // initializing
errorKey.keys() // will return object of unique keys with unique codes
errorKey.map() // return object similar to config file with unique code mapping
// you can simply get unique error code anywhere
try{
// ....
}catch(err){
const uniqueCode = errorKey.keys().invalidKey;
// uniqueCode is a number eg: 4001011 or 5021012
// read more detail about them below
}
You start by creating a unique configuration object anywhere in your project which you can pass to the initErrors
object.
statusCode
keys & in each key the error that you wish to declare with both key
& value
name similar.initErrors
function (see below)Note: The above example (in quick code) is the way your config object should be structured. You will receive an error while initializing if incorrect format is provided.
Simply initialize this anywhere in your project (ofcourse recommended way is in the very start itself)
initErrors(codes, config)
numbers
- if you wish to provide custom statusCodes
(provide []
if no custom codes)
init([888,999], errorObj)
init([], errorObj)
Twitter - @dawnimpulse
Email - dawnimpulse@gmail.com
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
error-key is free and unencumbered public domain software.
For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.
Written with StackEdit.
FAQs
simplify your project error handling & conveying issues to outside world
We found that error-key demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.