title: How to handle the Internal server error? Nestjs
body: <p>How to handle the error so that if the user does not provide a token, then an UnauthorizedException is thrown.</p>
  <p>At the moment I am getting this error:</p>
  <pre><code>{
      &quot;statusCode&quot;: 500,
      &quot;message&quot;: &quot;Internal server error&quot;
  }
  </code></pre>
  <p><strong>ts:</strong></p>
  <pre><code>  canActivate(context: ExecutionContext) {
      const request = context.switchToHttp().getRequest();
      try {
        const jwt = request.headers.authorization.split(' ')[1];
  
        if (!jwt) {
          throw new UnauthorizedException('Token is not provided.');
        }
  
        return this.jwtService.verify(jwt);
      } catch (e) {
        return false;
      }
    }
  </code></pre>