title: How to handle mongoose error with nestjs
body: <p>I followed the example from <a href="https://docs.nestjs.com/techniques/mongodb" rel="noreferrer">https://docs.nestjs.com/techniques/mongodb</a></p>
  
  <p>The issue is when there is a mongoose validation error (e.g i have a schema with a required field and it isn't provided):</p>
  
  <p>From games.service.ts:</p>
  
  <pre><code>  async create(createGameDto: CreateGameDto): Promise&lt;IGame&gt; {
      const createdGame = new this.gameModel(createGameDto);
      return await createdGame.save();
    }
  </code></pre>
  
  <p>The save() function returns a Promise.</p>
  
  <p>Now i have this in the game.controller.ts</p>
  
  <pre><code>  @Post()
    async create(@Body() createGameDto: CreateGameDto) {
      this.gamesService.create(createGameDto);
    }
  </code></pre>
  
  <p>What is the best way to handle an error and then return a response with a different http status and maybe a json text?
  You would usually throw a <code>HttpException</code> but from where? I can't do that if i handle the errors using .catch() in the promise.</p>
  
  <p>(Just started using the nestjs framework)</p>