Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceOverhaul/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/2.4.1/ProtobufCS/src/ProtocolBuffers/InvalidProtocolBufferException.cs

Last change on this file was 8295, checked in by abeham, 12 years ago

#1897:

  • Removed protocol buffers 0.9.1
  • Added protocol buffers 2.4.1
  • Updated proto processing command
File size: 4.7 KB
Line 
1#region Copyright notice and license
2
3// Protocol Buffers - Google's data interchange format
4// Copyright 2008 Google Inc.  All rights reserved.
5// http://github.com/jskeet/dotnet-protobufs/
6// Original C++/Java/Python code:
7// http://code.google.com/p/protobuf/
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13//     * Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//     * Redistributions in binary form must reproduce the above
16// copyright notice, this list of conditions and the following disclaimer
17// in the documentation and/or other materials provided with the
18// distribution.
19//     * Neither the name of Google Inc. nor the names of its
20// contributors may be used to endorse or promote products derived from
21// this software without specific prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35#endregion
36
37using System.IO;
38
39namespace Google.ProtocolBuffers
40{
41    /// <summary>
42    /// Thrown when a protocol message being parsed is invalid in some way,
43    /// e.g. it contains a malformed varint or a negative byte length.
44    /// </summary>
45    public sealed class InvalidProtocolBufferException : IOException
46    {
47        internal InvalidProtocolBufferException(string message)
48            : base(message)
49        {
50        }
51
52        public static InvalidProtocolBufferException TruncatedMessage()
53        {
54            return new InvalidProtocolBufferException(
55                "While parsing a protocol message, the input ended unexpectedly " +
56                "in the middle of a field.  This could mean either than the " +
57                "input has been truncated or that an embedded message " +
58                "misreported its own length.");
59        }
60
61        internal static InvalidProtocolBufferException NegativeSize()
62        {
63            return new InvalidProtocolBufferException(
64                "CodedInputStream encountered an embedded string or message " +
65                "which claimed to have negative size.");
66        }
67
68        public static InvalidProtocolBufferException MalformedVarint()
69        {
70            return new InvalidProtocolBufferException(
71                "CodedInputStream encountered a malformed varint.");
72        }
73
74        public static InvalidProtocolBufferException InvalidTag()
75        {
76            return new InvalidProtocolBufferException(
77                "Protocol message contained an invalid tag (zero).");
78        }
79
80        internal static InvalidProtocolBufferException InvalidEndTag()
81        {
82            return new InvalidProtocolBufferException(
83                "Protocol message end-group tag did not match expected tag.");
84        }
85
86        internal static InvalidProtocolBufferException InvalidWireType()
87        {
88            return new InvalidProtocolBufferException(
89                "Protocol message tag had invalid wire type.");
90        }
91
92        internal static InvalidProtocolBufferException RecursionLimitExceeded()
93        {
94            return new InvalidProtocolBufferException(
95                "Protocol message had too many levels of nesting.  May be malicious.  " +
96                "Use CodedInputStream.SetRecursionLimit() to increase the depth limit.");
97        }
98
99        internal static InvalidProtocolBufferException SizeLimitExceeded()
100        {
101            return new InvalidProtocolBufferException(
102                "Protocol message was too large.  May be malicious.  " +
103                "Use CodedInputStream.SetSizeLimit() to increase the size limit.");
104        }
105
106        internal static InvalidProtocolBufferException InvalidMessageStreamTag()
107        {
108            return new InvalidProtocolBufferException(
109                "Stream of protocol messages had invalid tag. Expected tag is length-delimited field 1.");
110        }
111    }
112}
Note: See TracBrowser for help on using the repository browser.