constructor(type, value, path, reason, schemaType) {
    // If no args, assume we'll `init()` later.
    if (arguments.length > 0) {
      const valueType = getValueType(value);
      const messageFormat = getMessageFormat(schemaType);
      const msg = formatMessage(null, type, value, path, messageFormat, valueType, reason);
      super(msg);
      this.init(type, value, path, reason, schemaType);
    } else {
      super(formatMessage());
    }
  }
Casting Error constructor.

@param {String} type
@param {String} value
@inherits MongooseError
@api private