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

Side by Side Diff: extensions/renderer/api_invocation_errors.h

Issue 2837023003: [Extensions Bindings] Add argument parsing errors (Closed)
Patch Set: rebase Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_
6 #define EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_
7
8 #include <string>
9
10 #include "base/strings/string_piece.h"
11
12 // A collection of error-related strings and utilities for parsing API
13 // invocations.
14 namespace extensions {
15 namespace api_errors {
16
17 // Strings for the expected types.
18 extern const char kTypeString[];
19 extern const char kTypeDouble[];
20 extern const char kTypeBoolean[];
21 extern const char kTypeInteger[];
22 extern const char kTypeObject[];
23 extern const char kTypeList[];
24 extern const char kTypeBinary[];
25 extern const char kTypeFunction[];
26 extern const char kTypeUndefined[];
27 extern const char kTypeNull[];
28
29 // Different errors that come up during argument parsing. Note: these messages
30 // often hold placeholders for printf; see the .cc file.
31 extern const char kInvalidEnumValue[];
32 extern const char kMissingRequiredProperty[];
33 extern const char kUnexpectedProperty[];
34 extern const char kTooFewArrayItems[];
35 extern const char kTooManyArrayItems[];
36 extern const char kTooFewStringChars[];
37 extern const char kTooManyStringChars[];
38 extern const char kNumberTooSmall[];
39 extern const char kNumberTooLarge[];
40 extern const char kInvalidType[];
41 extern const char kNotAnInstance[];
42 extern const char kInvalidChoice[];
43 extern const char kUnserializableValue[];
44 extern const char kScriptThrewError[];
45
46 // Utility methods to get a formatted error message.
47 std::string GetError(const char* error, int placeholder);
48 std::string GetError(const char* error, const char* placeholder);
49 std::string GetError(const char* error,
50 const char* placeholder1,
51 const char* placeholder2);
52
53 // Returns an message indicating an error was found while parsing a given index
54 // in an array.
55 std::string GetIndexError(uint32_t index, base::StringPiece error);
56
57 // Returns a message indicating that an error was found while parsing a given
58 // property on an object.
59 std::string GetPropertyError(base::StringPiece property_name,
60 base::StringPiece error);
61
62 } // namespace api_errors
63 } // namespace extensions
64
65 #endif // EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698