• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2008 Google Inc.  All rights reserved.
4 //
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file or at
7 // https://developers.google.com/open-source/licenses/bsd
8 #endregion
9 
10 using System;
11 
12 namespace Google.Protobuf.Reflection
13 {
14     /// <summary>
15     /// Thrown when building descriptors fails because the source DescriptorProtos
16     /// are not valid.
17     /// </summary>
18     public sealed class DescriptorValidationException : Exception
19     {
20         /// <value>
21         /// The full name of the descriptor where the error occurred.
22         /// </value>
23         public string ProblemSymbolName { get; }
24 
25         /// <value>
26         /// A human-readable description of the error. (The Message property
27         /// is made up of the descriptor's name and this description.)
28         /// </value>
29         public string Description { get; }
30 
DescriptorValidationException(IDescriptor problemDescriptor, string description)31         internal DescriptorValidationException(IDescriptor problemDescriptor, string description) :
32             base(problemDescriptor.FullName + ": " + description)
33         {
34             // Note that problemDescriptor may be partially uninitialized, so we
35             // don't want to expose it directly to the user.  So, we only provide
36             // the name and the original proto.
37             ProblemSymbolName = problemDescriptor.FullName;
38             Description = description;
39         }
40 
DescriptorValidationException(IDescriptor problemDescriptor, string description, Exception cause)41         internal DescriptorValidationException(IDescriptor problemDescriptor, string description, Exception cause) :
42             base(problemDescriptor.FullName + ": " + description, cause)
43         {
44             ProblemSymbolName = problemDescriptor.FullName;
45             Description = description;
46         }
47     }
48 }