@@ -36,6 +36,8 @@ bool debugLog(String message) {
3636// `null` for the `message` parameter and promptly dismiss the reported errors.
3737typedef ReportErrorCancellablyCallback = void Function (String ? message, {String ? details});
3838
39+ typedef ReportErrorCallback = void Function (String title, {String ? message});
40+
3941/// Show the user an error message, without requiring them to interact with it.
4042///
4143/// Typically this shows a [SnackBar] containing the message.
@@ -53,10 +55,25 @@ typedef ReportErrorCancellablyCallback = void Function(String? message, {String?
5355// the app.
5456ReportErrorCancellablyCallback reportErrorToUserBriefly = defaultReportErrorToUserBriefly;
5557
58+ /// Show the user a dismissable error message in a modal popup.
59+ ///
60+ /// Typically this shows an [AlertDialog] with `title` as the title, `message`
61+ /// as the body. If called before the app's widget tree is ready
62+ /// (see [ZulipApp.ready] ), then we give up on showing the message to the user,
63+ /// and just log the message to the console.
64+ // This gets set in [ZulipApp]. We need this indirection to keep `lib/log.dart`
65+ // from importing widget code, because the file is a dependency for the rest of
66+ // the app.
67+ ReportErrorCallback reportErrorToUserModally = defaultReportErrorToUserModally;
68+
5669void defaultReportErrorToUserBriefly (String ? message, {String ? details}) {
5770 _reportErrorToConsole (message, details);
5871}
5972
73+ void defaultReportErrorToUserModally (String title, {String ? message}) {
74+ _reportErrorToConsole (title, message);
75+ }
76+
6077void _reportErrorToConsole (String ? message, String ? details) {
6178 // Error dismissing is a no-op for the console.
6279 if (message == null ) return ;
0 commit comments