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


##########
playground/frontend/lib/modules/editor/components/share_dropdown/share_tabs/snippet_save_and_share_tabs.dart:
##########
@@ -16,32 +16,59 @@
  * limitations under the License.
  */
 
+import 'dart:async';
+
 import 'package:flutter/material.dart';
 import 
'package:playground/modules/editor/components/share_dropdown/share_tabs/example_share_tabs.dart';
 import 'package:playground_components/playground_components.dart';
 
-class SnippetSaveAndShareTabs extends StatelessWidget {
+class SnippetSaveAndShareTabs extends StatefulWidget {
+  final VoidCallback onError;
   final PlaygroundController playgroundController;
   final TabController tabController;
 
   const SnippetSaveAndShareTabs({
     super.key,
+    required this.onError,
     required this.playgroundController,
     required this.tabController,
   });
 
+  @override
+  State<SnippetSaveAndShareTabs> createState() => 
_SnippetSaveAndShareTabsState();
+}
+
+class _SnippetSaveAndShareTabsState extends State<SnippetSaveAndShareTabs> {
+  Future<String>? _future;
+
+  @override
+  void initState() {
+    super.initState();
+    unawaited(_initSaving());
+  }
+
+  Future<void> _initSaving() async {
+    try {
+      _future = widget.playgroundController.saveSnippet();
+      await _future;
+    } on Exception catch (ex) {
+      PlaygroundComponents.toastNotifier.addException(ex);
+      widget.onError();

Review Comment:
   With this message, the exception can be reused for anything we may be saving 
in the future. Until I am comfortable with the change, I want less exception 
classes. I am not comfortable yet. Let's see Tour of Beam adopt the error 
messages too.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to