Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
error-message-utils
Advanced tools
The error-message-utils package simplifies error management in your web applications and RESTful APIs. It ensures consistent and scalable handling of error messages, saving you time and effort. Moreover, it gives you the ability to assign custom error cod
The error-message-utils
package simplifies error management in your web applications and RESTful APIs. It ensures consistent and scalable handling of error messages, saving you time and effort. Moreover, it gives you the ability to assign custom error codes so all possible cases can be handled accordingly.
Install the package:
$ npm install -S error-message-utils
Encoding an error:
import { encodeError } from 'error-message-utils';
if (emailExists()) {
throw new Error(encodeError(
'The provided email is already in use.',
'EMAIL_EXISTS'
));
// 'The provided email is already in use.{(EMAIL_EXISTS)}'
}
Decoding an error:
import { decodeError } from 'error-message-utils';
decodeError('The provided email is already in use.{(EMAIL_EXISTS)}');
// {
// message: 'The provided email is already in use.',
// code: 'EMAIL_EXISTS'
// }
Error messages can be extracted recursively from complex structures, including nested cause
data properties from Error
instances:
import { extractMessage } from 'error-message-utils';
extractMessage(new Error('Top level error', {
cause: new Error('First nested cause', {
cause: new Error('Second nested cause'),
}),
}));
// 'Top level error; [CAUSE]: First nested cause; [CAUSE]: Second nested cause'
extractMessage({
message: {
err: {
message: 'This error message is nested deeply!'
}
}
});
// 'This error message is nested deeply!'
Identifying encoded errors:
import { isEncodedError, encodeError } from 'error-message-utils';
isEncodedError('Some random unencoded error');
// false
isEncodedError(new Error('Some random unencoded error'));
// false
isEncodedError(encodeError('Some unknown error.', 'NASTY_ERROR'));
// true
isEncodedError(encodeError(new Error('Some unknown error.'), 'NASTY_ERROR'));
// true
$ npm run test:unit
Install dependencies:
$ npm install
Build the library:
$ npm start
Publish to npm
:
$ npm publish
FAQs
The error-message-utils package simplifies error management in your web applications and RESTful APIs. It ensures consistent and scalable handling of error messages, saving you time and effort. Moreover, it gives you the ability to assign custom error cod
The npm package error-message-utils receives a total of 5 weekly downloads. As such, error-message-utils popularity was classified as not popular.
We found that error-message-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.