Skip to content

Commit 2ef825a

Browse files
committed
log [nfc]: Rename ReportErrorCallback to ReportErrorCancellablyCallback
This highlights the API choice that the callback signature allows the caller to clear/cancel the reported errors, by passing `null` for the `message` parameter, drawing distinction from a later added variant that does not allow this. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 02fe4e0 commit 2ef825a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/log.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ bool debugLog(String message) {
3131
return true;
3232
}
3333

34-
typedef ReportErrorCallback = void Function(String? message, {String? details});
34+
// This should only be used for error reporting functions that allow the error
35+
// to be cancelled programmatically. The implementation is expected to handle
36+
// `null` for the `message` parameter and promptly dismiss the reported errors.
37+
typedef ReportErrorCancellablyCallback = void Function(String? message, {String? details});
3538

3639
/// Show the user an error message, without requiring them to interact with it.
3740
///
@@ -48,7 +51,7 @@ typedef ReportErrorCallback = void Function(String? message, {String? details});
4851
// This gets set in [ZulipApp]. We need this indirection to keep `lib/log.dart`
4952
// from importing widget code, because the file is a dependency for the rest of
5053
// the app.
51-
ReportErrorCallback reportErrorToUserBriefly = defaultReportErrorToUserBriefly;
54+
ReportErrorCancellablyCallback reportErrorToUserBriefly = defaultReportErrorToUserBriefly;
5255

5356
void defaultReportErrorToUserBriefly(String? message, {String? details}) {
5457
// Error dismissing is a no-op to the default handler.

0 commit comments

Comments
 (0)