PageRenderTime 27ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/node_modules/mongoose/lib/error/notFound.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 50 lines | 25 code | 11 blank | 14 comment | 6 complexity | 6025fb5957cf2442c411f5da3f3d6536 MD5 | raw file
 1'use strict';
 2
 3/*!
 4 * Module dependencies.
 5 */
 6
 7var MongooseError = require('./');
 8var util = require('util');
 9
10/*!
11 * OverwriteModel Error constructor.
12 *
13 * @inherits MongooseError
14 */
15
16function DocumentNotFoundError(query) {
17  var msg;
18  var messages = MongooseError.messages;
19  if (messages.DocumentNotFoundError != null) {
20    msg = typeof messages.DocumentNotFoundError === 'function' ?
21      messages.DocumentNotFoundError(query) :
22      messages.DocumentNotFoundError;
23  } else {
24    msg = 'No document found for query "' + util.inspect(query) + '"';
25  }
26
27  MongooseError.call(this, msg);
28
29  this.name = 'DocumentNotFoundError';
30  if (Error.captureStackTrace) {
31    Error.captureStackTrace(this);
32  } else {
33    this.stack = new Error().stack;
34  }
35
36  this.query = query;
37}
38
39/*!
40 * Inherits from MongooseError.
41 */
42
43DocumentNotFoundError.prototype = Object.create(MongooseError.prototype);
44DocumentNotFoundError.prototype.constructor = MongooseError;
45
46/*!
47 * exports
48 */
49
50module.exports = DocumentNotFoundError;