Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/0.9.1/ProtobufCS/src/ProtocolBuffers/InvalidProtocolBufferException.cs @ 4032

Last change on this file since 4032 was 3857, checked in by abeham, 15 years ago

#866

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