OLD | NEW |
---|---|
(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 <set> | |
9 #include <string> | |
10 | |
11 #include "base/strings/string_piece.h" | |
12 | |
13 // A collection of error-related strings and utilities for parsing API | |
14 // invocations. | |
15 namespace extensions { | |
16 namespace api_errors { | |
17 | |
18 // Strings for the expected types. | |
19 extern const char kTypeString[]; | |
20 extern const char kTypeDouble[]; | |
21 extern const char kTypeBoolean[]; | |
22 extern const char kTypeInteger[]; | |
23 extern const char kTypeObject[]; | |
24 extern const char kTypeList[]; | |
25 extern const char kTypeBinary[]; | |
26 extern const char kTypeFunction[]; | |
27 extern const char kTypeUndefined[]; | |
28 extern const char kTypeNull[]; | |
29 | |
30 // Methods to return a formatted string describing an error related to argument | |
31 // parsing. | |
32 std::string InvalidEnumValue(const std::set<std::string>& valid_enums); | |
33 std::string MissingRequiredProperty(const char* property_name); | |
34 std::string UnexpectedProperty(const char* property_name); | |
35 std::string TooFewArrayItems(int minimum); | |
jbroman
2017/04/26 14:34:26
nit: You could also say how many were present (for
Devlin
2017/04/26 16:18:26
Why not. Done.
| |
36 std::string TooManyArrayItems(int maximum); | |
37 std::string TooFewStringChars(int minimum); | |
38 std::string TooManyStringChars(int maximum); | |
39 std::string NumberTooSmall(int minimum); | |
40 std::string NumberTooLarge(int maximum); | |
41 std::string InvalidType(const char* expected_type, const char* actual_type); | |
42 std::string NotAnInstance(const char* instance_type); | |
43 std::string InvalidChoice(); | |
44 std::string UnserializableValue(); | |
45 std::string ScriptThrewError(); | |
46 | |
47 // Returns an message indicating an error was found while parsing a given index | |
48 // in an array. | |
49 std::string IndexError(uint32_t index, const std::string& error); | |
50 | |
51 // Returns a message indicating that an error was found while parsing a given | |
52 // property on an object. | |
53 std::string PropertyError(const char* property_name, const std::string& error); | |
54 | |
55 } // namespace api_errors | |
56 } // namespace extensions | |
57 | |
58 #endif // EXTENSIONS_RENDERER_API_INVOCATION_ERRORS_H_ | |
OLD | NEW |