Filters: How Nest JS Handle Exceptions

Let us have a look, how effectively exceptions are handled in Nest JS

Renjith P
The Startup

--

Exception handling is an inevitable part of any programming language/framework. As we all know, it is one of the main area developers consider while choosing a programming language/framework to build a solution. So let us look into the trending framework Nest JS to see how effectively it handles exceptions.

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions

Standard Exception Handling

Nest JS comes with a built-in exceptions layer which is responsible for processing all unhandled exceptions across an application. When an exception is not handled by your application code, it is caught by this layer, which then automatically sends an appropriate user-friendly response.

Let us have an example to see how Nest JS handle standard exceptions like HttpException. Let us create a sample Nest JS application “nest-exception”.

nest new nest-exception
cd nest-exception
npm run start:dev

--

--