Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
my-error-handler
Advanced tools
A simple little stupid library to personal purpose.
Don't mind.
The library helps to handle errors into API projects.
npm i my-error-handler
import { ErrorHandler, MyErrorHandler } from 'my-error-handler';
// Service
const fooService = (foo?: object) => {
// code
// condition ...
if (!foo){
// Custom Error
const customError: ErrorHandler = {
message: "Not foo to process.",
error: { // Optional
code: 3256,
others: {
some: "foo"
}
}
};
const source: string = "./foo/foo.service";
const detail: string = "Process foo in all intances"; // Optional
// My Error Handler
throw MyErrorHandler.throw(customError, source, detail);
}
// more code
return foo;
}
// Controller
const fooController = () => {
try {
fooService();
} catch (error) {
// My Error Handler
throw MyErrorHandler.throw(error, "/foo/foo.controller");
}
}
// Caller
try {
fooController();
} catch (error) {
console.log("ERROR", error);
}
// Output
//
// ERROR {
// message: 'Not foo to process.',
// error: {
// code: 3256,
// others: {
// some: 'foo'
// }
// },
// trace: {
// source: '/user/foo.controller',
// detail: '',
// trace: {
// source: './user/foo.service',
// detail: 'Process foo in all intances',
// trace: null
// }
// }
// }
import { ErrorHandler, MyErrorHandler } from 'my-error-handler';
// Service
const fooService = (foo?: object): Observable<unknown> => {
// code
// condition ...
if (!foo){
// Custom Error
const customError: ErrorHandler = {
message: "Not foo to process.",
error: { // Optional
code: 3256,
others: {
some: "foo"
}
}
};
const source: string = "./foo/foo.service";
const detail: string = "Process foo in all intances"; // Optional
// My Error Handler
return MyErrorHandler.throwError(customError, source, detail); }
// more code
return createFoo$.pipe(
...
);
}
// Controller
const fooController$ = (): Observable<unknown> => {
// code
return from(fooService()).pipe(
// My Error Handler
catchError((error: any) => MyErrorHandler.throwError(error, "/foo/foo.controller"))
)
}
// Caller
fooController$().subscribe({
next: (res: any) => console.log(res),
error: (err: any) => console.log("ERROR", err)
})
// Output
//
// ERROR {
// message: 'Not foo to process.',
// error: {
// code: 3256,
// others: {
// some: 'foo'
// }
// },
// trace: {
// source: '/user/foo.controller',
// detail: '',
// trace: {
// source: './user/foo.service',
// detail: 'Process foo in all intances',
// trace: null
// }
// }
// }
FAQs
A simple little stupid library to personal purpose.
The npm package my-error-handler receives a total of 0 weekly downloads. As such, my-error-handler popularity was classified as not popular.
We found that my-error-handler 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
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.