com.google.protobuf
Class UninitializedMessageException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.google.protobuf.UninitializedMessageException
All Implemented Interfaces:
java.io.Serializable

public class UninitializedMessageException
extends java.lang.RuntimeException

Thrown when attempting to build a protocol message that is missing required fields. This is a RuntimeException because it normally represents a programming error: it happens when some code which constructs a message fails to set all the fields. parseFrom() methods do not throw this; they throw an InvalidProtocolBufferException if required fields are missing, because it is not a programming error to receive an incomplete message. In other words, UninitializedMessageException should never be thrown by correct code, but InvalidProtocolBufferException might be.

Author:
[email protected] Kenton Varda
See Also:
Serialized Form

Constructor Summary
UninitializedMessageException(Message message)
           
 
Method Summary
 InvalidProtocolBufferException asInvalidProtocolBufferException()
          Converts this exception to an InvalidProtocolBufferException.
 java.util.List<java.lang.String> getMissingFields()
          Get a list of human-readable names of required fields missing from this message.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UninitializedMessageException

public UninitializedMessageException(Message message)
Method Detail

getMissingFields

public java.util.List<java.lang.String> getMissingFields()
Get a list of human-readable names of required fields missing from this message. Each name is a full path to a field, e.g. "foo.bar[5].baz".


asInvalidProtocolBufferException

public InvalidProtocolBufferException asInvalidProtocolBufferException()
Converts this exception to an InvalidProtocolBufferException. When a parsed message is missing required fields, this should be thrown instead of UninitializedMessageException.



Copyright © 2008-2009. All Rights Reserved.