Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/mongoose/lib/error/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
/*!
* Module dependencies.
*/
const MongooseError = require('./mongooseError');
const get = require('../helpers/get');
const util = require('util');
/**
* Casting Error constructor.
*
* @param {String} type
* @param {String} value
* @inherits MongooseError
* @api private
*/
class CastError extends MongooseError {
constructor(type, value, path, reason, schemaType) {
// If no args, assume we'll `init()` later.
if (arguments.length > 0) {
const stringValue = getStringValue(value);
const messageFormat = getMessageFormat(schemaType);
const msg = formatMessage(null, type, stringValue, path, messageFormat);
super(msg);
this.init(type, value, path, reason, schemaType);
} else {
super(formatMessage());
}
}
/*!
* ignore
*/
init(type, value, path, reason, schemaType) {
this.stringValue = getStringValue(value);
this.messageFormat = getMessageFormat(schemaType);
this.kind = type;
this.value = value;
this.path = path;
this.reason = reason;
}
/*!
* ignore
* @param {Readonly<CastError>} other
*/
copy(other) {
this.messageFormat = other.messageFormat;
this.stringValue = other.stringValue;
this.kind = other.kind;
this.value = other.value;
this.path = other.path;
this.reason = other.reason;
this.message = other.message;
}
/*!
* ignore
*/
setModel(model) {
this.model = model;
this.message = formatMessage(model, this.kind, this.stringValue, this.path,
this.messageFormat);
}
}
Object.defineProperty(CastError.prototype, 'name', {
value: 'CastError'
});
function getStringValue(value) {
let stringValue = util.inspect(value);
stringValue = stringValue.replace(/^'|'$/g, '"');
if (!stringValue.startsWith('"')) {
stringValue = '"' + stringValue + '"';
}
return stringValue;
}
function getMessageFormat(schemaType) {
const messageFormat = get(schemaType, 'options.cast', null);
if (typeof messageFormat === 'string') {
return messageFormat;
}
}
/*!
* ignore
*/
function formatMessage(model, kind, stringValue, path, messageFormat) {
if (messageFormat != null) {
let ret = messageFormat.
replace('{KIND}', kind).
replace('{VALUE}', stringValue).
replace('{PATH}', path);
if (model != null) {
ret = ret.replace('{MODEL}', model.modelName);
}
return ret;
} else {
let ret = 'Cast to ' + kind + ' failed for value ' +
stringValue + ' at path "' + path + '"';
if (model != null) {
ret += ' for model "' + model.modelName + '"';
}
return ret;
}
}
/*!
* exports
*/
module.exports = CastError;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0314 ]-- |