You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/11/24 12:24:07 UTC

[GitHub] [beam] nausharipov commented on a diff in pull request #24338: Show error messages when Playground requests fail (#24033)

nausharipov commented on code in PR #24338:
URL: https://github.com/apache/beam/pull/24338#discussion_r1031420048


##########
playground/frontend/lib/modules/examples/examples_dropdown_content.dart:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:flutter/material.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+import 'package:playground/constants/links.dart';
+import 'package:playground/constants/sizes.dart';
+import 'package:playground/modules/examples/components/example_list/example_list.dart';
+import 'package:playground/modules/examples/components/filter/filter.dart';
+import 'package:playground/modules/examples/components/search_field/search_field.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:url_launcher/url_launcher.dart';
+
+class ExamplesDropdownContent extends StatefulWidget {
+  final VoidCallback onSelected;
+  final PlaygroundController playgroundController;
+
+  const ExamplesDropdownContent({
+    required this.onSelected,
+    required this.playgroundController,
+  });
+
+  @override
+  State<ExamplesDropdownContent> createState() =>
+      _ExamplesDropdownContentState();
+}
+
+class _ExamplesDropdownContentState extends State<ExamplesDropdownContent> {
+  final _searchController = TextEditingController();
+
+  @override
+  Widget build(BuildContext context) {
+    switch (widget.playgroundController.exampleCache.catalogStatus) {
+      case LoadingStatus.error:
+        return const LoadingErrorWidget();
+
+      case LoadingStatus.loading:
+        return const LoadingIndicator();
+
+      case LoadingStatus.done:
+        return _buildLoaded();
+    }
+  }
+
+  Widget _buildLoaded() {

Review Comment:
   It is not recommended to use helper methods over widgets: https://www.youtube.com/watch?v=IOyq-eTRhvo



##########
playground/frontend/playground_components/lib/src/cache/saving_exception.dart:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:easy_localization/easy_localization.dart';
+
+class SavingException implements Exception {

Review Comment:
   Why are `saving_exception` and `catalog_loading_exception` located in `cache`, while `example_loading_exception` is in` /exceptions`?



##########
playground/frontend/lib/modules/messages/handlers/set_content_message_handler.dart:
##########
@@ -34,11 +37,21 @@ class SetContentMessageHandler extends AbstractMessageHandler {
       return MessageHandleResult.notHandled;
     }
 
-    _handle(message);
+    unawaited(_handle(message));
     return MessageHandleResult.handled;
   }
 
-  void _handle(SetContentMessage message) {
-    playgroundController.examplesLoader.load(message.descriptor);
+  Future<void> _handle(SetContentMessage message) async {
+    final descriptor = message.descriptor;
+
+    try {
+      await playgroundController.examplesLoader.load(descriptor);

Review Comment:
   The code is repeated in `_load` of `playground_page_providers.dart`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org