在NodeJS本机驱动程序上,MongoDB示例错误看起来像什么? [英] What does an example MongoDB error look like on the NodeJS native driver?
本文介绍了在NodeJS本机驱动程序上,MongoDB示例错误看起来像什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎在其文档或互联网上找不到任何MongoDB错误对象的示例.
I can't seem to find any examples of MongoDB error objects in their documentation or on the internet.
MongoDB错误对象示例是什么样的?我想处理"错误和/或将其重新格式化以达到自己的目的,具体取决于错误的原因.
What does an example MongoDB error object look like? I'd like to "handle" the error and/or reformat it for my own purposes, depending on what the error is.
推荐答案
从带有mongodb
1.3.23驱动程序的MongoDB 2.4.8开始,它们看起来像这样:
As of MongoDB 2.4.8 with the mongodb
1.3.23 driver, they look like this:
{
"name":"MongoError",
"err":"E11000 duplicate key error index: test.test.$country_1 dup key: { : \"XYZ\" }",
"code":11000,
"n":0,
"connectionId":10706,
"ok":1
}
这篇关于在NodeJS本机驱动程序上,MongoDB示例错误看起来像什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文