refactor: 重命名 automation worker 为 general worker 并完善错误处理
This commit is contained in:
@@ -8,6 +8,7 @@ class LogEntry {
|
||||
final String? funcName;
|
||||
final int? lineNo;
|
||||
final String? errorType;
|
||||
final String? errorMessage;
|
||||
final String? stackTrace;
|
||||
final Map<String, dynamic>? extra;
|
||||
|
||||
@@ -19,6 +20,7 @@ class LogEntry {
|
||||
this.funcName,
|
||||
this.lineNo,
|
||||
this.errorType,
|
||||
this.errorMessage,
|
||||
this.stackTrace,
|
||||
this.extra,
|
||||
});
|
||||
@@ -31,6 +33,7 @@ class LogEntry {
|
||||
if (funcName != null) 'func_name': funcName,
|
||||
if (lineNo != null) 'line_no': lineNo,
|
||||
if (errorType != null) 'error_type': errorType,
|
||||
if (errorMessage != null) 'error_message': errorMessage,
|
||||
if (stackTrace != null) 'stack_trace': stackTrace,
|
||||
if (extra != null && extra!.isNotEmpty) 'extra': extra,
|
||||
};
|
||||
@@ -43,8 +46,9 @@ class LogEntry {
|
||||
].join('');
|
||||
final locationStr = location.isNotEmpty ? ' [$location]' : '';
|
||||
final errorStr = errorType != null ? ' [$errorType]' : '';
|
||||
final errorMsgStr = errorMessage != null ? ' $errorMessage' : '';
|
||||
final extraStr = extra != null && extra!.isNotEmpty ? ' $extra' : '';
|
||||
return '$ts ${level.name.toUpperCase().padRight(7)} [$module$locationStr]$errorStr $message$extraStr';
|
||||
return '$ts ${level.name.toUpperCase().padRight(7)} [$module$locationStr]$errorStr $message$errorMsgStr$extraStr';
|
||||
}
|
||||
|
||||
String toFileString() {
|
||||
@@ -59,6 +63,9 @@ class LogEntry {
|
||||
if (errorType != null) {
|
||||
sb.writeln(' Error: $errorType');
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
sb.writeln(' ErrorMessage: $errorMessage');
|
||||
}
|
||||
if (stackTrace != null) {
|
||||
sb.writeln(' StackTrace:');
|
||||
sb.writeln(stackTrace);
|
||||
|
||||
@@ -154,6 +154,7 @@ class LogService {
|
||||
funcName: funcName,
|
||||
lineNo: lineNo,
|
||||
errorType: error.runtimeType.toString(),
|
||||
errorMessage: error.toString(),
|
||||
stackTrace: stackTrace.toString(),
|
||||
extra: extra,
|
||||
),
|
||||
|
||||
@@ -72,8 +72,18 @@ class Logger {
|
||||
required StackTrace stackTrace,
|
||||
Map<String, dynamic>? extra,
|
||||
}) {
|
||||
final entry = LogEntry(
|
||||
timestamp: DateTime.now(),
|
||||
level: LogLevel.error,
|
||||
message: message,
|
||||
module: module,
|
||||
errorType: error.runtimeType.toString(),
|
||||
errorMessage: error.toString(),
|
||||
stackTrace: stackTrace.toString(),
|
||||
extra: extra,
|
||||
);
|
||||
if (_isNoOp) {
|
||||
debugPrint('[$module] ERROR: $message, error: $error');
|
||||
debugPrint(entry.toConsoleString());
|
||||
return;
|
||||
}
|
||||
_service!.error(
|
||||
|
||||
@@ -110,6 +110,7 @@ class ReminderSchedulerService {
|
||||
>();
|
||||
|
||||
final androidGranted = await android?.requestNotificationsPermission();
|
||||
await android?.requestExactAlarmsPermission();
|
||||
final iosGranted = await ios?.requestPermissions(alert: true, sound: true);
|
||||
final macosGranted = await macos?.requestPermissions(
|
||||
alert: true,
|
||||
|
||||
@@ -57,6 +57,8 @@ String? mapErrorCodeToL10nKey(
|
||||
return 'errorNotFound';
|
||||
case 'AGENT_USER_ID_INVALID':
|
||||
return 'errorGenericSafe';
|
||||
case 'AGENT_UPSTREAM_CONNECTION_ERROR':
|
||||
return 'errorNetwork';
|
||||
case 'INVALID_BINARY_URL_HOST':
|
||||
return 'errorAgentInvalidBinaryUrl';
|
||||
case 'INVALID_BINARY_URL_BUCKET':
|
||||
@@ -242,6 +244,8 @@ String? resolveErrorCodeMessage(
|
||||
return L10n.current.errorGenericSafe;
|
||||
case 'errorReLogin':
|
||||
return L10n.current.errorReLogin;
|
||||
case 'errorNetwork':
|
||||
return L10n.current.errorNetwork;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user