Remove path from error message
Omar committed
Jun 11, 2026 at 23:48 UTC
ff2a9958087c412ebbf236a1936edfd900bd13b1
1 file changed
+16
-7
cw_monero/lib/api/transaction_history.dart
+16
-7
@@ -17,6 +17,19 @@ import 'package:monero/src/generated_bindings_monero.g.dart' as monero_gen;
17
import 'package:mutex/mutex.dart';
18
19
20
+String _formatTransactionError(String error) {
21
+ final message = error.replaceAll(
22
+ RegExp(
23
+ r'(?:[A-Za-z]:)?[\\/][^\s:]*\.(?:c|cc|cpp|cxx|h|hpp|hxx):\d+:(?:[A-Za-z0-9_]+:)?\s*',
24
+ ),
25
+ '',
26
+ );
27
+ if (message.contains("RPC error")) {
28
+ return "Invalid node response, please try again or switch node\n\ntrace: $message";
29
+ }
30
+ return message;
31
+}
32
+
33
Map<int, Map<String, String>> txKeys = {};
34
String getTxKey(String txId) {
35
txKeys[currentWallet!.ffiAddress()] ??= {};
@@ -184,11 +197,7 @@ Future<PendingTransactionDescription> createTransactionSync(
197
})();
198
199
if (error != null) {
187
- String message = error;
188
- if (message.contains("RPC error")) {
189
- message = "Invalid node response, please try again or switch node\n\ntrace: $message";
190
- }
191
- throw CreationTransactionException(message: message);
200
+ throw CreationTransactionException(message: _formatTransactionError(error));
201
}
202
203
final rAmt = pendingTx.amount();
@@ -237,7 +246,7 @@ Future<PendingTransactionDescription> createTransactionMultDest(
246
final Wallet2PendingTransaction tx = MoneroPendingTransaction(txptr);
247
248
if (tx.status() != 0) {
240
- throw CreationTransactionException(message: tx.errorString());
249
+ throw CreationTransactionException(message: _formatTransactionError(tx.errorString()));
250
}
251
252
return PendingTransactionDescription(
@@ -282,7 +291,7 @@ Future<String?> commitTransaction({required Wallet2PendingTransaction tx, requir
291
292
}
293
if (error != null && error != "no tx keys found for this txid") {
285
- throw CreationTransactionException(message: error);
294
+ throw CreationTransactionException(message: _formatTransactionError(error));
295
}
296
unawaited(() async {
297
storeSync(force: true);