DescriptorValidationException.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Google.ProtocolBuffers.Descriptors {
  5. public class DescriptorValidationException : Exception {
  6. private readonly String name;
  7. private readonly IMessage proto;
  8. private readonly string description;
  9. /// <value>
  10. /// The full name of the descriptor where the error occurred.
  11. /// </value>
  12. public String ProblemSymbolName {
  13. get { return name; }
  14. }
  15. /// <value>
  16. /// The protocol message representation of the invalid descriptor.
  17. /// </value>
  18. public IMessage ProblemProto {
  19. get { return proto; }
  20. }
  21. /// <value>
  22. /// A human-readable description of the error. (The Message property
  23. /// is made up of the descriptor's name and this description.)
  24. /// </value>
  25. public string Description {
  26. get { return description; }
  27. }
  28. internal DescriptorValidationException(IDescriptor problemDescriptor, string description) :
  29. base(problemDescriptor.FullName + ": " + description) {
  30. // Note that problemDescriptor may be partially uninitialized, so we
  31. // don't want to expose it directly to the user. So, we only provide
  32. // the name and the original proto.
  33. name = problemDescriptor.FullName;
  34. proto = problemDescriptor.Proto;
  35. this.description = description;
  36. }
  37. internal DescriptorValidationException(IDescriptor problemDescriptor, string description, Exception cause) :
  38. base(problemDescriptor.FullName + ": " + description, cause) {
  39. name = problemDescriptor.FullName;
  40. proto = problemDescriptor.Proto;
  41. this.description = description;
  42. }
  43. }
  44. }