Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1337)

Unified Diff: lib/protobuf/runtime/PbException.dart

Issue 10595002: Protocol Buffer runtime library and 'protoc' plugin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Work around http://code.google.com/p/dart/issues/detail?id=3806 Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/protobuf/runtime/PbCodec.dart ('k') | lib/protobuf/runtime/PbImmutableList.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/protobuf/runtime/PbException.dart
diff --git a/lib/protobuf/runtime/PbException.dart b/lib/protobuf/runtime/PbException.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3c7ea3cc565cf629afe82a3e79b4766d90e8aec0
--- /dev/null
+++ b/lib/protobuf/runtime/PbException.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class PbException {
+ String message;
+
+ PbException(this.message) { }
+
+ String toString() => message;
+}
+
+class IllegalStateException extends PbException {
+ IllegalStateException(String message)
+ : super("IllegalStateException: $message") { }
+}
+
+class UninitializedMessageException extends PbException {
+ UninitializedMessageException(List<String> missingFields) :
+ super("Message missing required fields: "
+ "${Strings.join(missingFields, ', ')}");
+}
+
+class PbBufferBusyStateException extends PbException {
+ PbBufferBusyStateException() : super("PbBuffer in busy state.");
+}
+
+class InvalidProtocolBufferException extends PbException {
+
+ InvalidProtocolBufferException(String message) :
+ super("InvalidProtocolBufferException: $message") { }
+
+ static InvalidProtocolBufferException invalidEndTag() {
+ return new InvalidProtocolBufferException(
+ "Protocol message end-group tag did not match expected tag.");
+ }
+
+ static InvalidProtocolBufferException invalidTag() {
+ return new InvalidProtocolBufferException(
+ "Protocol message contained an invalid tag (zero).");
+ }
+
+ static InvalidProtocolBufferException invalidWireType() {
+ return new InvalidProtocolBufferException(
+ "Protocol message tag had invalid wire type.");
+ }
+
+ static InvalidProtocolBufferException malformedVarint() {
+ return new InvalidProtocolBufferException(
+ "CodedBufferReader encountered a malformed varint.");
+ }
+
+ static InvalidProtocolBufferException negativeSize() {
+ return new InvalidProtocolBufferException("""
+CodedBufferReader encountered an embedded string or message
+which claimed to have negative size.
+"""
+ );
+ }
+
+ static InvalidProtocolBufferException recursionLimitExceeded() {
+ return new InvalidProtocolBufferException("""
+Protocol message had too many levels of nesting. May be malicious.
+Use CodedBufferReader.setRecursionLimit() to increase the depth limit.
+"""
+ );
+ }
+
+ static InvalidProtocolBufferException sizeLimitExceeded() {
+ return new InvalidProtocolBufferException("""
+Protocol message was too large. May be malicious.
+Use CodedBufferReader.setSizeLimit() to increase the size limit.
+"""
+ );
+ }
+
+ static InvalidProtocolBufferException truncatedMessage() {
+ return new InvalidProtocolBufferException("""
+While parsing a protocol message, the input ended unexpectedly
+in the middle of a field. This could mean either than the
+input has been truncated or that an embedded message
+misreported its own length.
+"""
+ );
+ }
+}
« no previous file with comments | « lib/protobuf/runtime/PbCodec.dart ('k') | lib/protobuf/runtime/PbImmutableList.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698