@@ -31,7 +31,7 @@ constexpr char kTitleKey[] = "title";
3131constexpr char kViewIdKey [] = " viewId" ;
3232
3333// Error codes used for responses.
34- constexpr char kInvalidValueError [] = " Invalid Value " ;
34+ constexpr char kBadArgumentsError [] = " Bad Arguments " ;
3535constexpr char kUnavailableError [] = " Unavailable" ;
3636
3737// Retrieves the value associated with |key| from |map|, ensuring it matches
@@ -48,7 +48,7 @@ std::pair<std::optional<T>, bool> GetSingleValueForKeyOrSendError(
4848 flutter::MethodResult<>& result) {
4949 auto const it = map->find (flutter::EncodableValue (key));
5050 if (it == map->end ()) {
51- result.Error (kInvalidValueError ,
51+ result.Error (kBadArgumentsError ,
5252 " Map does not contain required '" + key + " ' key." );
5353 return {std::nullopt , false };
5454 }
@@ -59,7 +59,7 @@ std::pair<std::optional<T>, bool> GetSingleValueForKeyOrSendError(
5959 return {std::nullopt , true };
6060 }
6161
62- result.Error (kInvalidValueError , " Value for '" + key +
62+ result.Error (kBadArgumentsError , " Value for '" + key +
6363 " ' key must be of type '" +
6464 typeid (T).name () + " '." );
6565 return {std::nullopt , false };
@@ -81,7 +81,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
8181 flutter::MethodResult<>& result) {
8282 auto const it = map->find (flutter::EncodableValue (key));
8383 if (it == map->end ()) {
84- result.Error (kInvalidValueError ,
84+ result.Error (kBadArgumentsError ,
8585 " Map does not contain required '" + key + " ' key." );
8686 return {std::nullopt , false };
8787 }
@@ -91,7 +91,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
9191 if (auto const * const array =
9292 std::get_if<std::vector<flutter::EncodableValue>>(&it->second )) {
9393 if (Size && array->size () != Size) {
94- result.Error (kInvalidValueError , " Array for '" + key +
94+ result.Error (kBadArgumentsError , " Array for '" + key +
9595 " ' key must have " +
9696 std::to_string (Size) + " values." );
9797 return {std::nullopt , false };
@@ -104,7 +104,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
104104 if (std::holds_alternative<T>(value)) {
105105 decoded_values.push_back (std::get<T>(value));
106106 } else {
107- result.Error (kInvalidValueError ,
107+ result.Error (kBadArgumentsError ,
108108 " Array for '" + key +
109109 " ' key must only have values of type '" +
110110 typeid (T).name () + " '." );
@@ -114,7 +114,7 @@ std::pair<std::optional<std::vector<T>>, bool> GetListOfValuesForKeyOrSendError(
114114 return {std::move (decoded_values), true };
115115 }
116116
117- result.Error (kInvalidValueError ,
117+ result.Error (kBadArgumentsError ,
118118 " Value for key '" + key + " ' key must be an array." );
119119 return {std::nullopt , false };
120120}
@@ -160,7 +160,7 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
160160 auto const * const arguments = call.arguments ();
161161 auto const * const map = std::get_if<EncodableMap>(arguments);
162162 if (!map) {
163- result.Error (kInvalidValueError , " Method call argument is not a map." );
163+ result.Error (kBadArgumentsError , " Method call argument is not a map." );
164164 return ;
165165 }
166166
@@ -171,7 +171,7 @@ void WindowingHandler::HandleCreateWindow(WindowArchetype archetype,
171171 GetListOfValuesForKeyOrSendError<double , 2 >(kSizeKey , map, result);
172172 success) {
173173 if (!size_list.has_value ()) {
174- result.Error (kInvalidValueError , " Value for the '" +
174+ result.Error (kBadArgumentsError , " Value for the '" +
175175 std::string (kSizeKey ) +
176176 " ' key must not be null." );
177177 return ;
@@ -254,7 +254,7 @@ void WindowingHandler::HandleModifyWindow(WindowArchetype archetype,
254254 auto const * const arguments = call.arguments ();
255255 auto const * const map = std::get_if<EncodableMap>(arguments);
256256 if (!map) {
257- result.Error (kInvalidValueError , " Method call argument is not a map." );
257+ result.Error (kBadArgumentsError , " Method call argument is not a map." );
258258 return ;
259259 }
260260
@@ -266,7 +266,7 @@ void WindowingHandler::HandleModifyWindow(WindowArchetype archetype,
266266 GetSingleValueForKeyOrSendError<int >(kViewIdKey , map, result);
267267 success) {
268268 if (!data.has_value ()) {
269- result.Error (kInvalidValueError , " Value for the '" +
269+ result.Error (kBadArgumentsError , " Value for the '" +
270270 std::string (kViewIdKey ) +
271271 " ' key must not be null." );
272272 return ;
@@ -305,7 +305,7 @@ void WindowingHandler::HandleModifyWindow(WindowArchetype archetype,
305305 }
306306
307307 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 " +
309309 std::to_string (view_id) + " ." );
310310 }
311311
@@ -317,7 +317,7 @@ void WindowingHandler::HandleDestroyWindow(MethodCall<> const& call,
317317 auto const * const arguments = call.arguments ();
318318 auto const * const map = std::get_if<EncodableMap>(arguments);
319319 if (!map) {
320- result.Error (kInvalidValueError , " Method call argument is not a map." );
320+ result.Error (kBadArgumentsError , " Method call argument is not a map." );
321321 return ;
322322 }
323323
@@ -326,19 +326,19 @@ void WindowingHandler::HandleDestroyWindow(MethodCall<> const& call,
326326 GetSingleValueForKeyOrSendError<int >(kViewIdKey , map, result);
327327 success) {
328328 if (!view_id_opt.has_value ()) {
329- result.Error (kInvalidValueError , " Value for the '" +
329+ result.Error (kBadArgumentsError , " Value for the '" +
330330 std::string (kViewIdKey ) +
331331 " ' key must not be null." );
332332 return ;
333333 }
334334 if (*view_id_opt < 0 ) {
335- result.Error (kInvalidValueError ,
335+ result.Error (kBadArgumentsError ,
336336 " Value for '" + std::string (kViewIdKey ) + " ' (" +
337337 std::to_string (*view_id_opt) + " ) cannot be negative." );
338338 return ;
339339 }
340340 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 " +
342342 std::to_string (*view_id_opt) + " ." );
343343 return ;
344344 }
0 commit comments