<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="https://publishpress.com/"
	>

<channel>
	<title>Hoang Nguyen, Author at Tomoshare</title>
	<atom:link href="https://blog.tomosia.com.vn/author/nguyenhoang/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.tomosia.com.vn/author/nguyenhoang/</link>
	<description>Kênh chia sẻ kiến thức Tomosia Việt Nam</description>
	<lastBuildDate>Wed, 06 Dec 2023 01:26:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.tomosia.com.vn/wp-content/uploads/2023/09/cropped-icon-32x32.png</url>
	<title>Hoang Nguyen, Author at Tomoshare</title>
	<link>https://blog.tomosia.com.vn/author/nguyenhoang/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Exception Filters là gì? Xử lý Unhandled Error trong NestJS</title>
		<link>https://blog.tomosia.com.vn/exception-filters-la-gi-xu-ly-unhandled-error-trong-nestjs/</link>
					<comments>https://blog.tomosia.com.vn/exception-filters-la-gi-xu-ly-unhandled-error-trong-nestjs/#comments</comments>
		
		<dc:creator><![CDATA[Hoang Nguyen]]></dc:creator>
		<pubDate>Wed, 06 Dec 2023 01:26:04 +0000</pubDate>
				<category><![CDATA[Chưa phân loại]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">https://blog.tomosia.com.vn/?p=2337</guid>

					<description><![CDATA[<p>Exception Filters Trong quá trình coding thì chúng ta sẽ không thể tránh khỏi những trường hợp lỗi&#8230;</p>
<p>The post <a href="https://blog.tomosia.com.vn/exception-filters-la-gi-xu-ly-unhandled-error-trong-nestjs/">Exception Filters là gì? Xử lý Unhandled Error trong NestJS</a> appeared first on <a href="https://blog.tomosia.com.vn">Tomoshare</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 id="exception-filters" class="wp-block-heading">Exception Filters</h2>



<p>Trong quá trình coding thì chúng ta sẽ không thể tránh khỏi những trường hợp lỗi không mong muốn và nếu như chúng ta throw ra lỗi đó qua phía client thì có thể dẫn đến lỗi bảo mật hay trải nghiệm người dùng không tốt.</p>



<p>Để khắc phục tình trạng này thì NestJS có một <strong>Exception Layer</strong>. Layer này sẽ catch tất cả unhandled error và xử lý nó trước khi trả về Controller. Và tất nhiên chúng ta cũng có thể custom response hay handle lại error này trước khi nó được trả về.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="833" height="474" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-11.png" alt="" class="wp-image-2338" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-11.png 833w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-11-300x171.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-11-768x437.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-11-380x216.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-11-800x455.png 800w" sizes="(max-width: 833px) 100vw, 833px" /></figure>



<h2 id="default-response" class="wp-block-heading">Default Response</h2>



<pre class="wp-block-code"><code>{
  "statusCode": 500,
  "message": "Internal server error"
}</code></pre>



<h2 id="xu-ly-error-voi-exception-filters" class="wp-block-heading">Xử lý Error với Exception Filters</h2>



<p>Để có thể handle sao cho phù hợp với từng loại Error thì chúng ta có thể <strong>Catch</strong> những Error mà ta mong muốn</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:8.4296875px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">JavaScript</span><span role="button" tabindex="0" data-code="@Catch(HttpException) // Http Error

@Catch(PrismaException) // Database Error

@Catch(CustomErrorInstance) // Custom Error" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F6F6F4">@</span><span style="color: #62E884">Catch</span><span style="color: #F6F6F4">(</span><span style="color: #62E884; font-style: italic">HttpException</span><span style="color: #F6F6F4">) </span><span style="color: #7B7F8B">// Http Error</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">@</span><span style="color: #62E884">Catch</span><span style="color: #F6F6F4">(</span><span style="color: #62E884; font-style: italic">PrismaException</span><span style="color: #F6F6F4">) </span><span style="color: #7B7F8B">// Database Error</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">@</span><span style="color: #62E884">Catch</span><span style="color: #F6F6F4">(</span><span style="color: #62E884; font-style: italic">CustomErrorInstance</span><span style="color: #F6F6F4">) </span><span style="color: #7B7F8B">// Custom Error</span></span></code></pre></div>



<p>Sau khi đã <strong>Catch</strong> được Error mà mình mong muốn thì chúng ta sẽ phải implement lại class <strong>ExceptionFilter</strong> của NestJS và handle Error.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:16.859375px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">JavaScript</span><span role="button" tabindex="0" data-code="@Catch()
export class InternalExceptionFilter implements ExceptionFilter {
  async catch(exception: HttpException, context: GqlExecutionContext) {
    if (exception instanceof HttpException) {
      if (exception.getStatus() !== 500) return exception;
    }
    //Handle Error on production environment
    if (process.env.NODE_ENV !== &quot;development&quot;) {
      const ctx = GqlExecutionContext.create(context).getContext();
      const req: Request &amp; { user: Partial&lt;User&gt; | null } = ctx.req;
      const { query, operationName, variables } = req.body;
      const authorization = {
        laboId: req.header(&quot;labo-id&quot;),
        userId: req.user?.databaseId,
      };

      const errorParams: ErrorTemplateParams = {
        hostname: req.hostname,
        query,
        payload: JSON.stringify({ operationName, variables }, null, 2),
        stack: exception.stack,
        errorName: exception.name,
        authorization: JSON.stringify(authorization, null, 2),
      };

      const slack = new SlackService();
      slack.sendMessage(errorParams);
      // Return default error response
      return new InternalServerErrorException(&quot;Internal_Error&quot;);
    }
    // return error + stacktrace
    return exception;
  }
}" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F6F6F4">@</span><span style="color: #62E884">Catch</span><span style="color: #F6F6F4">()</span></span>
<span class="line"><span style="color: #F286C4">export</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">class</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1">InternalExceptionFilter</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">implements</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">ExceptionFilter</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"><span style="color: #F6F6F4">  </span><span style="color: #F286C4">async</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">catch</span><span style="color: #F6F6F4">(</span><span style="color: #FFB86C; font-style: italic">exception</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">HttpException</span><span style="color: #F6F6F4">, </span><span style="color: #FFB86C; font-style: italic">context</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">GqlExecutionContext</span><span style="color: #F6F6F4">) {</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #F286C4">if</span><span style="color: #F6F6F4"> (exception </span><span style="color: #F286C4">instanceof</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">HttpException</span><span style="color: #F6F6F4">) {</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">if</span><span style="color: #F6F6F4"> (exception.</span><span style="color: #62E884">getStatus</span><span style="color: #F6F6F4">() </span><span style="color: #F286C4">!==</span><span style="color: #F6F6F4"> </span><span style="color: #BF9EEE">500</span><span style="color: #F6F6F4">) </span><span style="color: #F286C4">return</span><span style="color: #F6F6F4"> exception;</span></span>
<span class="line"><span style="color: #F6F6F4">    }</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #7B7F8B">//Handle Error on production environment</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #F286C4">if</span><span style="color: #F6F6F4"> (process.env.</span><span style="color: #BF9EEE">NODE_ENV</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">!==</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">development</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">) {</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> ctx </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> GqlExecutionContext.</span><span style="color: #62E884">create</span><span style="color: #F6F6F4">(context).</span><span style="color: #62E884">getContext</span><span style="color: #F6F6F4">();</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> req</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">Request</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">&amp;</span><span style="color: #F6F6F4"> { user</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">Partial</span><span style="color: #F6F6F4">&lt;</span><span style="color: #FFB86C; font-style: italic">User</span><span style="color: #F6F6F4">&gt; </span><span style="color: #F286C4">|</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">null</span><span style="color: #F6F6F4"> } </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> ctx.req;</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> { query, operationName, variables } </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> req.body;</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> authorization </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"><span style="color: #F6F6F4">        laboId</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> req.</span><span style="color: #62E884">header</span><span style="color: #F6F6F4">(</span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">labo-id</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">),</span></span>
<span class="line"><span style="color: #F6F6F4">        userId</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> req.user?.databaseId,</span></span>
<span class="line"><span style="color: #F6F6F4">      };</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> errorParams</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #97E1F1; font-style: italic">ErrorTemplateParams</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"><span style="color: #F6F6F4">        hostname</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> req.hostname,</span></span>
<span class="line"><span style="color: #F6F6F4">        query,</span></span>
<span class="line"><span style="color: #F6F6F4">        payload</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #BF9EEE">JSON</span><span style="color: #F6F6F4">.</span><span style="color: #62E884">stringify</span><span style="color: #F6F6F4">({ operationName, variables }, </span><span style="color: #BF9EEE">null</span><span style="color: #F6F6F4">, </span><span style="color: #BF9EEE">2</span><span style="color: #F6F6F4">),</span></span>
<span class="line"><span style="color: #F6F6F4">        stack</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> exception.stack,</span></span>
<span class="line"><span style="color: #F6F6F4">        errorName</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> exception.name,</span></span>
<span class="line"><span style="color: #F6F6F4">        authorization</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #BF9EEE">JSON</span><span style="color: #F6F6F4">.</span><span style="color: #62E884">stringify</span><span style="color: #F6F6F4">(authorization, </span><span style="color: #BF9EEE">null</span><span style="color: #F6F6F4">, </span><span style="color: #BF9EEE">2</span><span style="color: #F6F6F4">),</span></span>
<span class="line"><span style="color: #F6F6F4">      };</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> slack </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">SlackService</span><span style="color: #F6F6F4">();</span></span>
<span class="line"><span style="color: #F6F6F4">      slack.</span><span style="color: #62E884">sendMessage</span><span style="color: #F6F6F4">(errorParams);</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #7B7F8B">// Return default error response</span></span>
<span class="line"><span style="color: #F6F6F4">      </span><span style="color: #F286C4">return</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">InternalServerErrorException</span><span style="color: #F6F6F4">(</span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">Internal_Error</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">);</span></span>
<span class="line"><span style="color: #F6F6F4">    }</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #7B7F8B">// return error + stacktrace</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #F286C4">return</span><span style="color: #F6F6F4"> exception;</span></span>
<span class="line"><span style="color: #F6F6F4">  }</span></span>
<span class="line"><span style="color: #F6F6F4">}</span></span></code></pre></div>



<p>Thì ở đây mình đã <strong>Catch</strong> tất cả Error bao gồm <strong>Http Error</strong> và <strong>Database Error</strong> chỉ ngoại trừ những lỗi 4xx đã throw ra.</p>



<p>Ở đây chúng ta có 2 tham số đó làm <strong>exception</strong> và <strong>context</strong> thì nó là cái gì?</p>



<p><strong>exception</strong> ở đây nó là lỗi nguyên bản nó thuộc về instance của <strong>Error</strong>. Thì trong exception nó sẽ bao gồm: stacktrace, message, errorName và error.</p>



<p><strong>context</strong> này nó được coi là host, chúng ta có thể sử dụng context này để có thể tham chiếu đến <strong>Request</strong> và <strong>Response</strong> và có thể custom lại Error chi tiết hơn để có thể tracking bug dễ dàng hơn.</p>



<h2 id="custom-response" class="wp-block-heading">Custom Response</h2>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="409" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-1024x409.png" alt="" class="wp-image-2340" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-1024x409.png 1024w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-300x120.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-768x307.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-1536x614.png 1536w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-380x152.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-800x320.png 800w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12-1160x464.png 1160w, https://blog.tomosia.com.vn/wp-content/uploads/2023/12/image-12.png 1584w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Và cuối cùng để NestJS có thể nhận được Exception Filter này thì t cần phải binding nó vào để có thể sử dụng như một global Filter.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:8.4296875px;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">main.ts</span><span role="button" tabindex="0" data-code="// Handle Internal Error
  if (process.env.NODE_ENV !== &quot;development&quot;) {
    app.useGlobalFilters(new InternalExceptionFilter());
  }" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #7B7F8B">// Handle Internal Error</span></span>
<span class="line"><span style="color: #F6F6F4">  </span><span style="color: #F286C4">if</span><span style="color: #F6F6F4"> (process.env.</span><span style="color: #BF9EEE">NODE_ENV</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">!==</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">development</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">) {</span></span>
<span class="line"><span style="color: #F6F6F4">    app.</span><span style="color: #62E884">useGlobalFilters</span><span style="color: #F6F6F4">(</span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">InternalExceptionFilter</span><span style="color: #F6F6F4">());</span></span>
<span class="line"><span style="color: #F6F6F4">  }</span></span></code></pre></div>



<h2 id="ket-bai" class="wp-block-heading">Kết bài:</h2>



<p>NestJS là framework hỗ trợ mạnh mẽ với nhiều tính năng và Exception Filters là một trong số đó. Thì ở bài này chúng ta đã tìm hiểu qua ExceptionFilter là gì và Handle những Unhandled Error như thế nào. </p>



<p>Hẹn gặp lại mọi người trong bài viết tìm hiểu về NestJS khác.</p>
<p>The post <a href="https://blog.tomosia.com.vn/exception-filters-la-gi-xu-ly-unhandled-error-trong-nestjs/">Exception Filters là gì? Xử lý Unhandled Error trong NestJS</a> appeared first on <a href="https://blog.tomosia.com.vn">Tomoshare</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tomosia.com.vn/exception-filters-la-gi-xu-ly-unhandled-error-trong-nestjs/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
