---
title: "Discussion on \"Handling Mongoose errors in a smart way\" | Hashnode"
description: "Discussion on \"Handling Mongoose errors in a smart way\". Instead of using third-party applications or using your own code, there is another way to handle errors like Duplicate Key Error, Mongoose bad ObjectId and others. \n\nFirst create a  Class like this:class ErrorResponse extends Error {constructor(messa..."
url: "https://hashnode.com/posts/handling-mongoose-errors-in-a-smart-way/61eb93955fbc177f9f3b3afd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Handling Mongoose errors in a smart way](https://mohitsaud.hashnode.dev/handling-mongoose-errors-in-a-smart-way?utm_source=hashnode&utm_medium=feed)

Instead of using third-party applications or using your own code, there is another way to handle errors like Duplicate Key Error, Mongoose bad ObjectId and others. First create a Class like this:class ErrorResponse extends Error {constructor(messa...

Jan 22, 2022 · 1 min read · mohitsaud.hashnode.dev  
Read the article

-   [#mongoose](https://hashnode.com/tag/mongoose)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#express](https://hashnode.com/tag/express)

## Written by

[Mohit Saud](https://hashnode.com/@mohitsaud)

@mohitsaud · Nepal

  
[View profile](https://hashnode.com/@mohitsaud)

Aspiring Software Developer

Watched a lot of movies during the early months of pandemic and one day decided to code and now it's my one of my favourite things to do. Coding boosts my mind, makes me focused and keeps motivated.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
