
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@n4it/utility-error-filter
Advanced tools
A NestJS module for catching and handling errors globally. The ErrorInterceptorModule
will catch all errors thrown in your NestJS application by default.
To install the module, use npm:
npm install @n4it/utility-error-filter
To use the ErrorInterceptorModule
, import it into your NestJS module and configure it using the register method. This method allows you to enable logging and handle specific errors globally.
import { ErrorInterceptorModule } from "@n4it/utility-error-filter";
import { Module } from "@nestjs/common";
@Module({
imports: [
ErrorInterceptorModule.register({
logErrros: true,
logFailures: true,
}),
],
})
export class AppModule {}
You can extend the module to handle custom errors, such as those from TypeORM
. This is done by mapping specific errors to HTTP status codes.
import { ErrorInterceptorModule } from "@n4it/utility-error-filter";
import { Module } from "@nestjs/common";
import {
CannotCreateEntityIdMapError,
EntityNotFoundError,
QueryFailedError,
} from "typeorm";
@Module({
imports: [
ErrorInterceptorModule.register({
// if you want to extend the working with custom errors
// for example, with TypeORM errors:
customErrorToStatusCodeMap: new Map([
[EntityNotFoundError.name, 404],
[CannotCreateEntityIdMapError.name, 422],
[QueryFailedError.name, 400],
])
}),
],
})
export class AppModule {}
You can extend the module to invoke a function when an unauthorized exception is throwed.
import { ErrorInterceptorModule } from "@n4it/utility-error-filter";
import { Module, ArgumentsHost, HttpException } from "@nestjs/common";
@Module({
imports: [
ErrorInterceptorModule.register({
onUnauthorized: (exception: HttpException, host: ArgumentsHost) => {
// do something here, for example, delete session cookies
}
}),
],
})
export class AppModule {}
You can extend the module to send alerts to slack.
import { ErrorInterceptorModule } from "@n4it/utility-error-filter";
import { Module, ArgumentsHost, HttpException } from "@nestjs/common";
@Module({
imports: [
ErrorInterceptorModule.register({
slackWebhook: {
url: "https://hooks.slack.com/services/XXXXXXX/XXXXXX/XXXXXX"
}
}),
],
})
export class AppModule {}
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request or open an issue on GitHub.
If you have any questions or need support, you can contact us at info@n4it.nl.
FAQs
Better error handling for NestJS
We found that @n4it/utility-error-filter demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.