@@ -31,7 +31,7 @@ constexpr char kTitleKey[] = "title";
31
31
constexpr char kViewIdKey [] = " viewId" ;
32
32
33
33
// Error codes used for responses.
34
- constexpr char kInvalidValueError [] = " Invalid Value " ;
34
+ constexpr char kBadArgumentsError [] = " Bad Arguments " ;
35
35
constexpr char kUnavailableError [] = " Unavailable" ;
36
36
37
37
// Retrieves the value associated with |key| from |map|, ensuring it matches
@@ -48,7 +48,7 @@ std::pair<std::optional<T>, bool> GetSingleValueForKeyOrSendError(
48
48
flutter::MethodResult<>& result) {
49
49
auto const it = map->find (flutter::EncodableValue (key));
50
50
if (it == map->end ()) {
51
- result.Error (kInvalidValueError ,
51
+ result.Error (kBadArgumentsError ,
52
52
" Map does not contain required '" + key + " ' key." );
53
53
return {std::nullopt, false };
54
54
}
@@ -59,7 +59,7 @@ std::pair<std::optional<T>, bool> GetSingleValueForKeyOrSendError(
59
59
return {std::nullopt, true };
60
60
}
61
61
62
- result.Error (kInvalidValueError , " Value for '" + key +
62
+ result.Error (kBadArgumentsError , " Value for '" + key +
63
63
" ' key must be of type '" +
64
64
typeid (T).name () + " '." );
65
65
return {std::nullopt, false };
@@ -81,7 +81,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
81
81
flutter::MethodResult<>& result) {
82
82
auto const it = map->find (flutter::EncodableValue (key));
83
83
if (it == map->end ()) {
84
- result.Error (kInvalidValueError ,
84
+ result.Error (kBadArgumentsError ,
85
85
" Map does not contain required '" + key + " ' key." );
86
86
return {std::nullopt, false };
87
87
}
@@ -91,7 +91,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
91
91
if (auto const * const array =
92
92
std::get_if<std::vector<flutter::EncodableValue>>(&it->second )) {
93
93
if (Size && array->size () != Size ) {
94
- result.Error (kInvalidValueError , " Array for '" + key +
94
+ result.Error (kBadArgumentsError , " Array for '" + key +
95
95
" ' key must have " +
96
96
std::to_string (Size ) + " values." );
97
97
return {std::nullopt, false };
@@ -104,7 +104,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
104
104
if (std::holds_alternative<T>(value)) {
105
105
decoded_values.push_back (std::get<T>(value));
106
106
} else {
107
- result.Error (kInvalidValueError ,
107
+ result.Error (kBadArgumentsError ,
108
108
" Array for '" + key +
109
109
" ' key must only have values of type '" +
110
110
typeid (T).name () + " '." );
@@ -114,7 +114,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
114
114
return {std::move (decoded_values), true };
115
115
}
116
116
117
- result.Error (kInvalidValueError ,
117
+ result.Error (kBadArgumentsError ,
118
118
" Value for key '" + key + " ' key must be an array." );
119
119
return {std::nullopt, false };
120
120
}
@@ -160,7 +160,7 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
160
160
auto const * const arguments = call.arguments ();
161
161
auto const * const map = std::get_if<EncodableMap>(arguments);
162
162
if (!map) {
163
- result.Error (kInvalidValueError , " Method call argument is not a map." );
163
+ result.Error (kBadArgumentsError , " Method call argument is not a map." );
164
164
return ;
165
165
}
166
166
@@ -171,7 +171,7 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
171
171
GetListOfValuesForKeyOrSendError<double , 2 >(kSizeKey , map, result);
172
172
success) {
173
173
if (!size_list.has_value ()) {
174
- result.Error (kInvalidValueError , " Value for the '" +
174
+ result.Error (kBadArgumentsError , " Value for the '" +
175
175
std::string (kSizeKey ) +
176
176
" ' key must not be null." );
177
177
return ;
@@ -254,7 +254,7 @@ void WindowingHandler::HandleModifyWindow(WindowArchetype archetype,
254
254
auto const * const arguments = call.arguments ();
255
255
auto const * const map = std::get_if<EncodableMap>(arguments);
256
256
if (!map) {
257
- result.Error (kInvalidValueError , " Method call argument is not a map." );
257
+ result.Error (kBadArgumentsError , " Method call argument is not a map." );
258
258
return ;
259
259
}
260
260
@@ -266,7 +266,7 @@ void WindowingHandler::HandleModifyWindow(WindowArchetype archetype,
266
266
GetSingleValueForKeyOrSendError<int >(kViewIdKey , map, result);
267
267
success) {
268
268
if (!data.has_value ()) {
269
- result.Error (kInvalidValueError , " Value for the '" +
269
+ result.Error (kBadArgumentsError , " Value for the '" +
270
270
std::string (kViewIdKey ) +
271
271
" ' key must not be null." );
272
272
return ;
@@ -305,7 +305,7 @@ void WindowingHandler::HandleModifyWindow(WindowArchetype archetype,
305
305
}
306
306
307
307
if (!controller_->ModifyHostWindow (view_id, settings)) {
308
- result.Error (kInvalidValueError , " Can't find window with view ID " +
308
+ result.Error (kBadArgumentsError , " Can't find window with view ID " +
309
309
std::to_string (view_id) + " ." );
310
310
}
311
311
@@ -317,7 +317,7 @@ void WindowingHandler::HandleDestroyWindow(MethodCall<> const& call,
317
317
auto const * const arguments = call.arguments ();
318
318
auto const * const map = std::get_if<EncodableMap>(arguments);
319
319
if (!map) {
320
- result.Error (kInvalidValueError , " Method call argument is not a map." );
320
+ result.Error (kBadArgumentsError , " Method call argument is not a map." );
321
321
return ;
322
322
}
323
323
@@ -326,19 +326,19 @@ void WindowingHandler::HandleDestroyWindow(MethodCall<> const& call,
326
326
GetSingleValueForKeyOrSendError<int >(kViewIdKey , map, result);
327
327
success) {
328
328
if (!view_id_opt.has_value ()) {
329
- result.Error (kInvalidValueError , " Value for the '" +
329
+ result.Error (kBadArgumentsError , " Value for the '" +
330
330
std::string (kViewIdKey ) +
331
331
" ' key must not be null." );
332
332
return ;
333
333
}
334
334
if (*view_id_opt < 0 ) {
335
- result.Error (kInvalidValueError ,
335
+ result.Error (kBadArgumentsError ,
336
336
" Value for '" + std::string (kViewIdKey ) + " ' (" +
337
337
std::to_string (*view_id_opt) + " ) cannot be negative." );
338
338
return ;
339
339
}
340
340
if (!controller_->DestroyHostWindow (*view_id_opt)) {
341
- result.Error (kInvalidValueError , " Can't find window with view ID " +
341
+ result.Error (kBadArgumentsError , " Can't find window with view ID " +
342
342
std::to_string (*view_id_opt) + " ." );
343
343
return ;
344
344
}
0 commit comments