handle method
Method called when report has been accepted by user
Implementation
@override
Future<bool> handle(Report report, BuildContext? context) async {
try {
if (!(await CatcherUtils.isInternetConnectionAvailable())) {
_printLog("No internet connection available");
return false;
}
String message = "";
if (customMessageBuilder != null) {
message = await customMessageBuilder!(report);
} else {
message = _buildMessage(report);
}
final data = {
"text": message,
"channel": channel,
"username": username,
"icon_emoji": iconEmoji
};
_printLog("Sending request to Slack server...");
final Response response =
await _dio.post<dynamic>(webhookUrl, data: data);
_printLog(
"Server responded with code: ${response.statusCode} and message: ${response.statusMessage}",
);
final statusCode = response.statusCode ?? 0;
return statusCode >= 200 && statusCode < 300;
} catch (exception) {
_printLog("Failed to send slack message: $exception");
return false;
}
}