PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
NestJS interceptors and exception filters capture failures at different boundaries. An interceptor can observe an error emitted by the downstream observable from next.handle(); a filter handles an exception that remains uncaught after that path. Guards run before interceptors, and a route-level filter that handles an exception does not pass it on to a global filter. The built-in exception layer can return an HTTP error response without logging an ordinary HttpException.
Those distinctions determine where to record an error, why an expected failure may be missing from logs, and whether a monitoring integration sees the original exception or a replacement. The right capture point depends on where the error originates and which layer ultimately handles it.
What is the difference between a NestJS interceptor and an exception filter?
An interceptor wraps the handler execution path and can inspect errors that travel through the observable returned by next.handle(). An exception filter handles an uncaught exception and controls how it becomes an HTTP response. They are not interchangeable catch-all hooks.
Free tools Windows power users keep installed
One-click scans. No signup required.
NestJS’s request lifecycle places middleware and guards before interceptors. Pipes, the controller and its services run within the handler path that an active interceptor wraps. On the inbound request, interceptors run global, then controller, then route; their return path unwinds in reverse. See the NestJS request lifecycle documentation for the framework’s ordering.
Popular on Amazon
- 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
- 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
- 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
- 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
- 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.
| Failure or behavior | Can an interceptor’s catchError observe it? |
Can an exception filter handle it? | What to check |
|---|---|---|---|
| A guard denies a request | No: guards run before interceptors. | An applicable filter can handle an uncaught exception. | Do not assume a global interceptor sees guard failures. |
| A pipe rejects input, or a controller or service throws | Yes, if the interceptor invoked next.handle() and the failure reaches its observable. |
Yes, if the error remains uncaught after interceptor operators. | Trace whether the original error was rethrown, replaced or converted to a successful result. |
| An interceptor maps an error to a different exception | It observes the prior error while applying the mapping. | It receives the new uncaught exception. | Keep the original cause distinct from the mapped exception type. |
| A route filter handles the exception | No later observable capture should be assumed. | The route filter handles it; filters do not relay it to other filters. | Put reporting at the handling boundary or share reporting behavior deliberately. |
| Nest-managed middleware throws or passes an error onward | No: middleware precedes interceptors. | Only global filters apply to middleware exceptions. | A route-filter-only reporting strategy will not cover this boundary. |
An interceptor does not call next.handle() |
There is no downstream handler execution for that interceptor to observe. | Handling depends on whether the interceptor returns a value or throws an exception. | Check for short-circuiting if the controller’s expected error is absent. |
NestJS explicitly documents that errors from pipes, controllers or services can be read in an interceptor’s catchError operator in its request lifecycle guide. The framework’s interceptor guide shows error handling through observable operators. Neither statement means every failure in a request passes through an interceptor.
Why isn’t my NestJS global filter catching the error?
First identify which filter actually handles the exception. NestJS checks route-level filters, then controller-level filters, then global filters. A filter that matches and handles the error ends that filter chain; a global filter is not automatically a second reporting hook.
Check the exception’s scope
A filter attached to a route or controller can take precedence over a global filter for exceptions in that scope. If it handles the exception and sends the response, do not expect the global filter to receive the same exception afterward. If both scopes need the same reporting behavior, put that behavior in shared code and invoke it from the applicable handling points rather than relying on filter-to-filter forwarding. The ordering and catch-scope rules are described in the NestJS exception filters guide.
Check whether the throw happened before interceptors
A guard executes before the interceptor chain. Middleware executes earlier still. An interceptor’s catchError therefore cannot be the sole mechanism for capturing guard or middleware failures. NestJS documents that only global filters apply to exceptions from Nest-managed middleware; a route-scoped filter does not cover that earlier lifecycle stage.
Check whether the interceptor short-circuited
An interceptor may return its own observable without calling next.handle(). In that case, the controller and service do not run through that interceptor’s downstream path, so there is no downstream handler error for its catchError operator to observe. Decide whether the interceptor’s own return or thrown error is handled by a filter based on what it emits.
Also popular on Amazon
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
What does catchError do to an HTTP exception?
Applied to next.handle(), catchError can inspect an emitted failure, rethrow it, replace it with another error, or return a successful observable instead. Those choices change what remains for the exception filter to handle.
Observe and rethrow
If the goal is reporting without changing HTTP behavior, report the error and rethrow the same object:
return next.handle().pipe(
catchError(error => {
report(error);
return throwError(() => error);
}),
);
report here represents application-specific reporting logic, not a NestJS-provided method. Rethrowing preserves the exception for downstream handling. Choose a single intended reporting boundary where possible: reporting in both an interceptor and a filter can create duplicate events unless the reporting design deduplicates them.
Replace the error
NestJS’s interceptor documentation illustrates mapping an error to another exception, such as replacing a downstream failure with a BadGatewayException. If the replacement escapes the interceptor, the filter receives that replacement. A log at the filter boundary may therefore show the mapped exception rather than the original throw type. When the distinction matters, retain the original error as a cause where appropriate and record both identities safely.
Recover with a successful observable
If catchError returns a normal value or another successful observable, the original failure no longer remains an uncaught exception on that path. A filter should not be expected to handle the recovered error as if it had escaped. This follows from the documented observable mapping behavior and the rule that exception filters handle uncaught exceptions; it is not a claim about a test result.
Also popular on Amazon
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Why isn’t HttpException logged by default?
NestJS’s built-in exception layer formats HTTP exceptions into responses, but it does not log built-in HttpException instances by default. The exception filter documentation states: “By default, the exception filter does not log built-in exceptions such as HttpException (and any exceptions that inherit from it).” A valid client response is therefore not evidence that an error was reported to an operational log or monitoring service.
By default, the built-in handler uses the response information on an HttpException; for unrecognized errors it returns a generic 500 response rather than exposing internal error details. If expected HTTP exceptions need to be recorded, add deliberate reporting through a custom filter, logger or monitoring integration. A custom logger alone should not be assumed to capture every built-in HTTP exception: select the capture boundary explicitly.
Choose which exceptions to catch
Use @Catch(HttpException) when a filter is meant to handle expected HTTP exceptions. Use @Catch() when it must also handle unexpected exception types. A broad filter needs a careful policy: anticipated client-side 4xx conditions may be operationally different from unexpected 5xx defects, and the response body should not expose internal details merely because the filter can access them.
Keep error identity separate from client output
An HttpException can retain an underlying cause without serializing that cause into the public response. Its errorCode, when supplied, is serialized for clients. Treat response fields as an explicit public contract: do not include a raw cause, stack trace, credentials, request secrets or other sensitive context. Send sanitized diagnostic context to logs or monitoring instead. NestJS documents these exception options in its exception filters guide.
How do I add a filter without tying it to Express?
Use Nest’s adapter abstractions when the application may run on Express or Fastify. A filter example that calls Express-specific response.json() is not automatically portable to Fastify; the official adapter-based catch-all pattern avoids assuming one response API.
Also popular on Amazon
- Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
- Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
- 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
- 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
- Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.
- Choose the catch scope. Decide whether the filter handles only
HttpExceptionor all exceptions, then apply the appropriate@Catch(...)decorator. - Read the execution context. Use
ArgumentsHostto access the HTTP request and response context when constructing an HTTP response. - Use the adapter where portability matters. Inject
HttpAdapterHostand use its HTTP adapter to send the response in a way that works across supported adapters. - Preserve default handling when extending it. If extending
BaseExceptionFilterand intending to retain Nest’s default processing, delegate withsuper.catch(exception, host). - Register at the intended scope. Register a global filter with
APP_FILTERwhen dependency injection is required. NestJS also documents other global registration approaches; choose one that matches the filter’s dependencies and application setup. - Set a reporting policy separately from response formatting. Decide which exceptions are reported, what context is safe to send, how correlation is added, and how duplicate events are avoided.
The current NestJS exception filter documentation includes the adapter-based catch-all pattern and registration guidance. Its current pages may document behavior newer than a deployed application’s version; confirm the framework and adapter versions before copying code. In particular, NestJS documents a change to http-errors exposure behavior starting in v12.2, so applications on earlier versions should not assume that change applies.
Which reporting approach fits my application?
Choose based on where failures occur, how much control you need over responses, and whether hosted capture or portable traces matter. No option should be assumed to capture every boundary or report each error only once without checking its integration behavior.
| Approach | Useful when | Trade-offs and checks |
|---|---|---|
| Custom filter plus logger | You need control over the HTTP response schema and an application-defined reporting policy. | You must implement correlation, privacy scrubbing and operational search. NestJS’s filter and logging hooks do not themselves provide a hosted defect dashboard. |
| NestJS Observe | You want Nest-specific error monitoring; its documentation says it can capture errors escaping controllers and other entry points with their request and trace without a filter call. | The vendor distinguishes expected exceptions shown in Errors from unhandled defects eligible for alerts. Consider the hosted-service model and export limitations; these are vendor-described capabilities, not independent performance measurements. |
| Sentry NestJS SDK | You already use that monitoring service and want to integrate exception capture with Nest filters. | The official SDK README describes using @SentryExceptionCaptured() with an existing global catch-all filter, or adding SentryGlobalFilter when there is no such filter. Check the installed SDK version because an older changelog documents different integration names. |
| OpenTelemetry-compatible backend | You need OTLP portability, mixed-language traces or a self-hosting option. | Tracing does not by itself prove that the backend captures the desired exception boundaries or applies the intended 4xx/5xx policy. NestJS’s OpenTelemetry documentation warns that, at the time it was written, its three Nest-specific spans were not recorded with NestJS 12; verify support for the versions actually deployed. |
Relevant primary references are NestJS’s error monitoring guide, its exception filter documentation, and the Sentry NestJS SDK README. Vendor documentation describes product behavior, not independent performance results. For any integration, compare original-versus-mapped error visibility, coverage before interceptors, request and trace correlation, adapter and transport coverage, version maintenance, self-hosting needs, response control and duplicate-report risk.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How can I verify which boundary handles each error?
Use a controlled set of routes and record four observations for every case: the client status and body, whether an interceptor observed the error, which filter handled it, and whether a monitoring event was emitted. This is a suggested verification plan based on NestJS’s documented boundaries, not a claim that these cases have been run.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
- Throw a
BadRequestExceptionfrom a service and note whether the interceptor sees it and which filter creates the response. - Reject input in a validation pipe and record whether the downstream interceptor observes the resulting exception.
- Deny a request in a guard and confirm whether your interceptor-based reporting sees anything.
- Throw from Nest-managed middleware and check whether the global filter handles it.
- Map an error to a new exception in
catchError; compare the interceptor’s observed original error with the filter’s exception. - Handle a failure with a route filter while a global filter is also registered; check which filter runs and whether a single monitoring event is produced.
- Throw an ordinary unexpected
Errorand compare its response and reporting behavior with an expected HTTP exception. - If both Express and Fastify are supported, repeat a response check on each adapter to catch response-API assumptions.
Keep the error identity, chosen filter and event count in the record rather than checking only the HTTP status. That makes it easier to find whether an error vanished through recovery, was mapped, was handled at a narrower scope, or was never on the interceptor path.
Also popular on Amazon
- 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
- 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
- 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
- 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
- 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.
Frequently Asked Questions
Can I use a NestJS interceptor to catch guard errors?
No. Guards run before interceptors in NestJS’s request lifecycle, so an interceptor around the handler cannot be relied on to observe a guard denial. Use a filter or instrumentation that covers the earlier boundary.
Does a NestJS exception filter automatically log every failed request?
No. The built-in filter does not log built-in HttpException instances by default, and custom filters only report what their implementation records. An HTTP error response and an operational monitoring event are separate outcomes.
How can I correlate NestJS errors with requests?
NestJS documents injectable custom loggers, AsyncLocalStorage and monitoring-based trace correlation as approaches. Choose a correlation mechanism that is available at the error’s lifecycle boundary and avoid putting secrets into correlation metadata.
Recommended Free Tools
Does NestJS 12 support the same OpenTelemetry spans as earlier versions?
NestJS’s OpenTelemetry documentation warns that, at the time it was written, three Nest-specific spans were not recorded with NestJS 12. Verify the current compatibility guidance for the exact NestJS and instrumentation versions in the application.

