Skip to content

Commit

Permalink
Add more exception capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkrieger committed Apr 19, 2022
1 parent 257c5dc commit 5fb7329
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions lib/repositories/ios_speech_recognizer.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

const iosPlatform = MethodChannel("voiceoutliner.saga.chat/iostx");

Expand All @@ -13,8 +14,9 @@ Future<String?> recognizeNoteIOS(String path, String locale) async {
} else {
return null;
}
} catch (err) {
} catch (err, tr) {
print(err);
Sentry.captureException(err, stackTrace: tr);
return null;
}
}
Expand Down Expand Up @@ -42,8 +44,8 @@ Future<Map<String, String>> getLocaleOptions() async {
try {
final res = await iosPlatform.invokeMethod("getLocaleOptions");
return Map<String, String>.from(res);
} catch (err) {
print(err);
} catch (err, tr) {
Sentry.captureException(err, stackTrace: tr);
return {};
}
}
12 changes: 8 additions & 4 deletions lib/repositories/vosk_speech_recognizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_archive/flutter_archive.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:voice_outliner/consts.dart';

Expand Down Expand Up @@ -50,7 +51,8 @@ Future<String?> voskSpeechRecognize(String path) async {
final result =
await androidPlatform.invokeMethod("transcribe", {"path": outPath});
return result;
} catch (err) {
} catch (err, tr) {
Sentry.captureException(err, stackTrace: tr);
print(err);
return null;
}
Expand All @@ -68,8 +70,9 @@ Future<String?> voskInitModel(String path) async {
return res.toString();
}
return null;
} catch (e) {
return e.toString();
} catch (err, tr) {
Sentry.captureException(err, stackTrace: tr);
return err.toString();
}
}

Expand Down Expand Up @@ -103,7 +106,8 @@ Future<String?> voskDownloadAndInitModel(String url) async {
final sharedPreferences = await SharedPreferences.getInstance();
await sharedPreferences.setString(modelDirKey, modelDir.path);
return null;
} catch (err) {
} catch (err, tr) {
Sentry.captureException(err, stackTrace: tr);
return err.toString();
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.22.2+91
version: 1.22.3+92

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 5fb7329

Please sign in to comment.