浏览代码

Catch mongo errors

Tati 7 年之前
父节点
当前提交
06d98d84ba
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      ktchn/src/recipes/controller.ts

+ 1 - 1
ktchn/src/recipes/controller.ts

@@ -11,7 +11,7 @@ const saveRecipe = (db: IMongoService) => ({ body }: Request, res: Response, nex
     db.insertOne(body).then(DBRecipe => {
       res.json(DBRecipe);
       next();
-    })
+    }).catch(error => { next(error) })
   } else {
     next(new Error('Missing recipe information'));
   }