@@ -1429,12 +1429,25 @@ class _SavedSnippetComposeBoxBody extends _ComposeBoxBody {
14291429 return Align (
14301430 alignment: Alignment .centerRight,
14311431 child: IconButton (
1432- onPressed: () {
1433- Navigator .pop (context);
1434- // TODO handle validation errors; server errors
1435- createSavedSnippet (store.connection,
1436- title: controller.title.textNormalized,
1437- content: controller.content.textNormalized);
1432+ onPressed: () async {
1433+ // TODO client-side validations
1434+ try {
1435+ await createSavedSnippet (store.connection,
1436+ title: controller.title.textNormalized,
1437+ content: controller.content.textNormalized);
1438+ if (! context.mounted) return ;
1439+ Navigator .pop (context);
1440+ } on ApiRequestException catch (e) {
1441+ if (! context.mounted) return ;
1442+ final zulipLocalizations = ZulipLocalizations .of (context);
1443+ final message = switch (e) {
1444+ ZulipApiException () => zulipLocalizations.errorServerMessage (e.message),
1445+ _ => e.message,
1446+ };
1447+ showErrorDialog (context: context,
1448+ title: zulipLocalizations.errorFailedToCreateSavedSnippet,
1449+ message: message);
1450+ }
14381451 }, icon: Icon (ZulipIcons .check, color: designVariables.icon)));
14391452 }
14401453}
0 commit comments