# Logging Errors with unreachable code

**URL:** <https://forum.codewithmosh.com/t/logging-errors-with-unreachable-code/3621>\
**Category:** Node\
**Created:** [March 27, 2021, 6:16pm UTC](https://forum.codewithmosh.com/t/logging-errors-with-unreachable-code/3621 "2021-03-27T18:16:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [March 27, 2021, 6:16pm UTC](https://forum.codewithmosh.com/t/logging-errors-with-unreachable-code/3621/1 "2021-03-27T18:16:26Z")

</div>

So my Logging error works as expected, however with this line of code:

```
      throw new Error("Could not get the genres.")

```

the code down below it in my router.get function is “unreachable”. Is that expected?

Here’s my code:

```
  router.get("/", async (req, res) => {
     throw new Error("Could not get the genres.");
     const genres = await Genre.find().sort("name");
     res.send(genres);
 });

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/c/c10a0a3d2c0b7578a327013c707c4c5d04f3d655.png)
