Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Generic Error handler
npm i thrown
// logger function is optional
// logger => internal logger
import errorHandler, { genericError, logger } from 'thrown'
// without options
function thisIsFunction() {
try {
throw genericError('this is message', { /* ... */ })
} catch (err) {
errorHandler(err)
}
}
// with options : case 1
function thisIsFunction() {
try {
throw genericError.create('prefix >')('this is message', { /* ... */ })
// or
throw genericError.create({ prefix: 'prefix >' })('this is message', { /* ... */ })
} catch (err) {
errorHandler(err)
}
}
// with options : case 2
function thisIsFunction() {
try {
throw genericError('this is message', { /* ... */ })
} catch (err) {
errorHandler.extra({
// if set `externalLogger`, no use internal logger
// internal logger uses `console.group`
externalLogger: (message, err, stack) => {
console.log(message, err);
console.log(stack);
}
})(err)
}
}
// with options : case 3
function thisIsFunction() {
try {
throw genericError.('this is message', { /* ... */ })
} catch (err) {
errorHandler.extra({
// additional information
handler: (err) => {
// compute something
// this object will combine with original error object
// should be an object (not array)
return { computedErr }
}
})(err)
}
}
import errorHandler from 'thrown'
try {
throw new Error('this is error')
} catch (err) {
// all options are optional
errorHandler.extra({
// no display in production
mode: process.env.NODE_ENV,
// css text eg. 'font-size: 10px;'
style: '',
// default <thrown>
name: 'any name',
// default true (group or groupCollapsed)
expanded: true,
// default false (console.trace), if trace false, it uses error.stack
trace: false,
// use external logger
externalLogger: (message, err, stack) => {
console.log(message, err);
console.log(stack);
},
// combine additional information with original error
handler: (err) => {
const computedErr = {
return { computedErr }
}
})(err)
}
MIT
FAQs
Generic Error Handler
We found that thrown 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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.