aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/GPBMessage.h
diff options
context:
space:
mode:
authorGravatar Sergio Campamá <kaipi@google.com>2016-06-02 11:14:26 -0700
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-06-02 14:14:26 -0400
commite34c09182ebe0ed2958aefa809159498923743d3 (patch)
tree2eaf97f34c4ece1c6391fb795b20acc2d46fa145 /objectivec/GPBMessage.h
parent0ab7a7f74458be56bfc65a71a46711637ee5962b (diff)
Improving the granularity parsing errors (#1623)
Add more context to GPBCodedInputStream failures. Have GPBMessage parsing apis extract out the GPBCodedInputStream information and expose it. Update HeaderDocs with pointers to all error domains/codes. Expand the unittests to cover the full set of errors reported. Fixes https://github.com/google/protobuf/issues/1618
Diffstat (limited to 'objectivec/GPBMessage.h')
-rw-r--r--objectivec/GPBMessage.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/objectivec/GPBMessage.h b/objectivec/GPBMessage.h
index 2249829f..b3b07793 100644
--- a/objectivec/GPBMessage.h
+++ b/objectivec/GPBMessage.h
@@ -49,12 +49,15 @@ extern NSString *const GPBMessageErrorDomain;
/// Error code for NSError with GPBMessageErrorDomain.
typedef NS_ENUM(NSInteger, GPBMessageErrorCode) {
- /// The data being parsed is bad and a message can not be created from it.
- GPBMessageErrorCodeMalformedData = -100,
+ /// Uncategorized error.
+ GPBMessageErrorCodeOther = -100,
/// A message can't be serialized because it is missing required fields.
GPBMessageErrorCodeMissingRequiredField = -101,
};
+/// Key under which the error's reason is stored inside the userInfo dictionary.
+extern NSString *const GPBErrorReasonKey;
+
CF_EXTERN_C_END
/// Base class for all of the generated message classes.
@@ -86,6 +89,9 @@ CF_EXTERN_C_END
/// @note In DEBUG builds, the parsed message is checked to be sure all required
/// fields were provided, and the parse will fail if some are missing.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param data The data to parse.
/// @param errorPtr An optional error pointer to fill in with a failure reason if
/// the data can not be parsed.
@@ -101,6 +107,9 @@ CF_EXTERN_C_END
/// @note In DEBUG builds, the parsed message is checked to be sure all required
/// fields were provided, and the parse will fail if some are missing.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param data The data to parse.
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure
@@ -119,6 +128,9 @@ CF_EXTERN_C_END
/// @note In DEBUG builds, the parsed message is checked to be sure all required
/// fields were provided, and the parse will fail if some are missing.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param input The stream to read data from.
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure
@@ -139,6 +151,9 @@ CF_EXTERN_C_END
/// the required fields are set. So this method can be used to reload
/// messages that may not be complete.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param input The stream to read data from.
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure
@@ -158,6 +173,9 @@ CF_EXTERN_C_END
/// @note In DEBUG builds, the parsed message is checked to be sure all required
/// fields were provided, and the parse will fail if some are missing.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param data The data to parse.
/// @param errorPtr An optional error pointer to fill in with a failure reason if
/// the data can not be parsed.
@@ -171,6 +189,9 @@ CF_EXTERN_C_END
/// @note In DEBUG builds, the parsed message is checked to be sure all required
/// fields were provided, and the parse will fail if some are missing.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param data The data to parse.
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure
@@ -188,6 +209,9 @@ CF_EXTERN_C_END
/// the required fields are set. So this method can be used to reload
/// messages that may not be complete.
///
+/// @note The errors returned are likely coming from the domain and codes listed
+/// at the top of this file and GPBCodedInputStream.h.
+///
/// @param input The stream to read data from.
/// @param extensionRegistry The extension registry to use to look up extensions.
/// @param errorPtr An optional error pointer to fill in with a failure