Source: proto/spine/base/error_pb.js

// source: spine/base/error.proto
/**
 * @fileoverview
 * @enhanceable
 * @suppress {messageConventions} JS Compiler reports an error if a variable or
 *     field starts with 'MSG_' and isn't a translatable message.
 * @public
 */
// GENERATED CODE -- DO NOT EDIT!

var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();

var spine_options_pb = require('../../spine/options_pb.js');
goog.object.extend(proto, spine_options_pb);
var google_protobuf_struct_pb = require('../../google/protobuf/struct_pb.js');
goog.object.extend(proto, google_protobuf_struct_pb);
var spine_validate_validation_error_pb = require('../../spine/validate/validation_error_pb.js');
goog.object.extend(proto, spine_validate_validation_error_pb);
goog.exportSymbol('proto.spine.base.Error', null, global);
/**
 * Generated by JsPbCodeGenerator.
 * @param {Array=} opt_data Optional initial data array, typically from a
 * server response, or constructed directly in Javascript. The array is used
 * in place and becomes part of the constructed object. It is not cloned.
 * If no data is provided, the constructed object will be empty, but still
 * valid.
 * @extends {jspb.Message}
 * @constructor
 */
proto.spine.base.Error = function(opt_data) {
  jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.spine.base.Error, jspb.Message);
if (goog.DEBUG && !COMPILED) {
  /**
   * @public
   * @override
   */
  proto.spine.base.Error.displayName = 'proto.spine.base.Error';
}



if (jspb.Message.GENERATE_TO_OBJECT) {
/**
 * Creates an object representation of this proto.
 * Field names that are reserved in JavaScript and will be renamed to pb_name.
 * Optional fields that are not set will be set to undefined.
 * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
 * For the list of reserved names please see:
 *     net/proto2/compiler/js/internal/generator.cc#kKeyword.
 * @param {boolean=} opt_includeInstance Deprecated. whether to include the
 *     JSPB instance for transitional soy proto support:
 *     http://goto/soy-param-migration
 * @return {!Object}
 */
proto.spine.base.Error.prototype.toObject = function(opt_includeInstance) {
  return proto.spine.base.Error.toObject(opt_includeInstance, this);
};


/**
 * Static version of the {@see toObject} method.
 * @param {boolean|undefined} includeInstance Deprecated. Whether to include
 *     the JSPB instance for transitional soy proto support:
 *     http://goto/soy-param-migration
 * @param {!proto.spine.base.Error} msg The msg instance to transform.
 * @return {!Object}
 * @suppress {unusedLocalVariables} f is only used for nested messages
 */
proto.spine.base.Error.toObject = function(includeInstance, msg) {
  var f, obj = {
    type: jspb.Message.getFieldWithDefault(msg, 1, ""),
    code: jspb.Message.getFieldWithDefault(msg, 2, 0),
    validationError: (f = msg.getValidationError()) && spine_validate_validation_error_pb.ValidationError.toObject(includeInstance, f),
    message: jspb.Message.getFieldWithDefault(msg, 10, ""),
    attributesMap: (f = msg.getAttributesMap()) ? f.toObject(includeInstance, proto.google.protobuf.Value.toObject) : [],
    stacktrace: jspb.Message.getFieldWithDefault(msg, 12, "")
  };

  if (includeInstance) {
    obj.$jspbMessageInstance = msg;
  }
  return obj;
};
}


/**
 * Deserializes binary data (in protobuf wire format).
 * @param {jspb.ByteSource} bytes The bytes to deserialize.
 * @return {!proto.spine.base.Error}
 */
proto.spine.base.Error.deserializeBinary = function(bytes) {
  var reader = new jspb.BinaryReader(bytes);
  var msg = new proto.spine.base.Error;
  return proto.spine.base.Error.deserializeBinaryFromReader(msg, reader);
};


/**
 * Deserializes binary data (in protobuf wire format) from the
 * given reader into the given message object.
 * @param {!proto.spine.base.Error} msg The message object to deserialize into.
 * @param {!jspb.BinaryReader} reader The BinaryReader to use.
 * @return {!proto.spine.base.Error}
 */
proto.spine.base.Error.deserializeBinaryFromReader = function(msg, reader) {
  while (reader.nextField()) {
    if (reader.isEndGroup()) {
      break;
    }
    var field = reader.getFieldNumber();
    switch (field) {
    case 1:
      var value = /** @type {string} */ (reader.readString());
      msg.setType(value);
      break;
    case 2:
      var value = /** @type {number} */ (reader.readInt32());
      msg.setCode(value);
      break;
    case 3:
      var value = new spine_validate_validation_error_pb.ValidationError;
      reader.readMessage(value,spine_validate_validation_error_pb.ValidationError.deserializeBinaryFromReader);
      msg.setValidationError(value);
      break;
    case 10:
      var value = /** @type {string} */ (reader.readString());
      msg.setMessage(value);
      break;
    case 11:
      var value = msg.getAttributesMap();
      reader.readMessage(value, function(message, reader) {
        jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.google.protobuf.Value.deserializeBinaryFromReader, "", new proto.google.protobuf.Value());
         });
      break;
    case 12:
      var value = /** @type {string} */ (reader.readString());
      msg.setStacktrace(value);
      break;
    default:
      reader.skipField();
      break;
    }
  }
  return msg;
};


/**
 * Serializes the message to binary data (in protobuf wire format).
 * @return {!Uint8Array}
 */
proto.spine.base.Error.prototype.serializeBinary = function() {
  var writer = new jspb.BinaryWriter();
  proto.spine.base.Error.serializeBinaryToWriter(this, writer);
  return writer.getResultBuffer();
};


/**
 * Serializes the given message to binary data (in protobuf wire
 * format), writing to the given BinaryWriter.
 * @param {!proto.spine.base.Error} message
 * @param {!jspb.BinaryWriter} writer
 * @suppress {unusedLocalVariables} f is only used for nested messages
 */
proto.spine.base.Error.serializeBinaryToWriter = function(message, writer) {
  var f = undefined;
  f = message.getType();
  if (f.length > 0) {
    writer.writeString(
      1,
      f
    );
  }
  f = message.getCode();
  if (f !== 0) {
    writer.writeInt32(
      2,
      f
    );
  }
  f = message.getValidationError();
  if (f != null) {
    writer.writeMessage(
      3,
      f,
      spine_validate_validation_error_pb.ValidationError.serializeBinaryToWriter
    );
  }
  f = message.getMessage();
  if (f.length > 0) {
    writer.writeString(
      10,
      f
    );
  }
  f = message.getAttributesMap(true);
  if (f && f.getLength() > 0) {
    f.serializeBinary(11, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.google.protobuf.Value.serializeBinaryToWriter);
  }
  f = message.getStacktrace();
  if (f.length > 0) {
    writer.writeString(
      12,
      f
    );
  }
};


/**
 * optional string type = 1;
 * @return {string}
 */
proto.spine.base.Error.prototype.getType = function() {
  return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};


/**
 * @param {string} value
 * @return {!proto.spine.base.Error} returns this
 */
proto.spine.base.Error.prototype.setType = function(value) {
  return jspb.Message.setProto3StringField(this, 1, value);
};


/**
 * optional int32 code = 2;
 * @return {number}
 */
proto.spine.base.Error.prototype.getCode = function() {
  return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
};


/**
 * @param {number} value
 * @return {!proto.spine.base.Error} returns this
 */
proto.spine.base.Error.prototype.setCode = function(value) {
  return jspb.Message.setProto3IntField(this, 2, value);
};


/**
 * optional spine.validate.ValidationError validation_error = 3;
 * @return {?proto.spine.validate.ValidationError}
 */
proto.spine.base.Error.prototype.getValidationError = function() {
  return /** @type{?proto.spine.validate.ValidationError} */ (
    jspb.Message.getWrapperField(this, spine_validate_validation_error_pb.ValidationError, 3));
};


/**
 * @param {?proto.spine.validate.ValidationError|undefined} value
 * @return {!proto.spine.base.Error} returns this
*/
proto.spine.base.Error.prototype.setValidationError = function(value) {
  return jspb.Message.setWrapperField(this, 3, value);
};


/**
 * Clears the message field making it undefined.
 * @return {!proto.spine.base.Error} returns this
 */
proto.spine.base.Error.prototype.clearValidationError = function() {
  return this.setValidationError(undefined);
};


/**
 * Returns whether this field is set.
 * @return {boolean}
 */
proto.spine.base.Error.prototype.hasValidationError = function() {
  return jspb.Message.getField(this, 3) != null;
};


/**
 * optional string message = 10;
 * @return {string}
 */
proto.spine.base.Error.prototype.getMessage = function() {
  return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 10, ""));
};


/**
 * @param {string} value
 * @return {!proto.spine.base.Error} returns this
 */
proto.spine.base.Error.prototype.setMessage = function(value) {
  return jspb.Message.setProto3StringField(this, 10, value);
};


/**
 * map<string, google.protobuf.Value> attributes = 11;
 * @param {boolean=} opt_noLazyCreate Do not create the map if
 * empty, instead returning `undefined`
 * @return {!jspb.Map<string,!proto.google.protobuf.Value>}
 */
proto.spine.base.Error.prototype.getAttributesMap = function(opt_noLazyCreate) {
  return /** @type {!jspb.Map<string,!proto.google.protobuf.Value>} */ (
      jspb.Message.getMapField(this, 11, opt_noLazyCreate,
      proto.google.protobuf.Value));
};


/**
 * Clears values from the map. The map will be non-null.
 * @return {!proto.spine.base.Error} returns this
 */
proto.spine.base.Error.prototype.clearAttributesMap = function() {
  this.getAttributesMap().clear();
  return this;};


/**
 * optional string stacktrace = 12;
 * @return {string}
 */
proto.spine.base.Error.prototype.getStacktrace = function() {
  return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 12, ""));
};


/**
 * @param {string} value
 * @return {!proto.spine.base.Error} returns this
 */
proto.spine.base.Error.prototype.setStacktrace = function(value) {
  return jspb.Message.setProto3StringField(this, 12, value);
};


goog.object.extend(exports, proto.spine.base);

// Generated by Spine ProtoJs Plugin

let ObjectParser = require('../../../client/parser/object-parser.js').default;
let TypeParsers = require('../../../client/parser/type-parsers.js').default;

proto.spine.base.Error.Parser = function() {
  ObjectParser.call(this);
};
proto.spine.base.Error.Parser.prototype = Object.create(ObjectParser.prototype);
proto.spine.base.Error.Parser.prototype.constructor = proto.spine.base.Error.Parser;
proto.spine.base.Error.Parser.prototype.fromObject = function(obj) {
  if (obj === null) {
    return null;
  }
  
  let msg = new proto.spine.base.Error();
  
  if (obj.type !== undefined) {
    if (obj.type !== null) {
      let value = obj.type;
      msg.setType(value);
    }
  }
  
  if (obj.code !== undefined) {
    if (obj.code !== null) {
      let value = obj.code;
      msg.setCode(value);
    }
  }
  
  if (obj.validationError !== undefined) {
    if (obj.validationError === null) {
      msg.setValidationError(null);
    } else {
      let value = TypeParsers.parserFor('type.spine.io/spine.validate.ValidationError').fromObject(obj.validationError);
      msg.setValidationError(value);
    }
  }
  
  if (obj.message !== undefined) {
    if (obj.message !== null) {
      let value = obj.message;
      msg.setMessage(value);
    }
  }
  
  if (obj.attributes !== undefined && obj.attributes !== null) {
    for (let attribute in obj.attributes) {
      if (obj.attributes.hasOwnProperty(attribute)) {
        let mapKey = attribute;
        let value = TypeParsers.parserFor('type.googleapis.com/google.protobuf.Value').fromObject(obj.attributes[attribute]);
        msg.getAttributesMap().set(mapKey, value);
      }
    }
  }
  
  if (obj.stacktrace !== undefined) {
    if (obj.stacktrace !== null) {
      let value = obj.stacktrace;
      msg.setStacktrace(value);
    }
  }
  return msg;
};

// Generated by Spine ProtoJs Plugin
proto.spine.base.Error.typeUrl = function() {
  return 'type.spine.io/spine.base.Error';
};