Index: extensions/renderer/api_invocation_errors.h |
diff --git a/extensions/renderer/api_invocation_errors.h b/extensions/renderer/api_invocation_errors.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1a508e4e7652df7df5cbd7f04e051531864804a3 |
--- /dev/null |
+++ b/extensions/renderer/api_invocation_errors.h |
@@ -0,0 +1,65 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_ |
+#define EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_ |
+ |
+#include <string> |
+ |
+#include "base/strings/string_piece.h" |
+ |
+// A collection of error-related strings and utilities for parsing API |
+// invocations. |
+namespace extensions { |
+namespace api_errors { |
+ |
+// Strings for the expected types. |
+extern const char kTypeString[]; |
+extern const char kTypeDouble[]; |
+extern const char kTypeBoolean[]; |
+extern const char kTypeInteger[]; |
+extern const char kTypeObject[]; |
+extern const char kTypeList[]; |
+extern const char kTypeBinary[]; |
+extern const char kTypeFunction[]; |
+extern const char kTypeUndefined[]; |
+extern const char kTypeNull[]; |
+ |
+// Different errors that come up during argument parsing. Note: these messages |
+// often hold placeholders for printf; see the .cc file. |
+extern const char kInvalidEnumValue[]; |
+extern const char kMissingRequiredProperty[]; |
+extern const char kUnexpectedProperty[]; |
+extern const char kTooFewArrayItems[]; |
+extern const char kTooManyArrayItems[]; |
+extern const char kTooFewStringChars[]; |
+extern const char kTooManyStringChars[]; |
+extern const char kNumberTooSmall[]; |
+extern const char kNumberTooLarge[]; |
+extern const char kInvalidType[]; |
+extern const char kNotAnInstance[]; |
+extern const char kInvalidChoice[]; |
+extern const char kUnserializableValue[]; |
+extern const char kScriptThrewError[]; |
+ |
+// Utility methods to get a formatted error message. |
+std::string GetError(const char* error, int placeholder); |
+std::string GetError(const char* error, const char* placeholder); |
+std::string GetError(const char* error, |
+ const char* placeholder1, |
+ const char* placeholder2); |
+ |
+// Returns an message indicating an error was found while parsing a given index |
+// in an array. |
+std::string GetIndexError(uint32_t index, base::StringPiece error); |
+ |
+// Returns a message indicating that an error was found while parsing a given |
+// property on an object. |
+std::string GetPropertyError(base::StringPiece property_name, |
+ base::StringPiece error); |
+ |
+} // namespace api_errors |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_ |