Skip to content

Commit

Permalink
better error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHeitmann committed Jul 7, 2024
1 parent 1757400 commit 5bd7249
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions lib/background/wemFilesIndexer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class WemFilesLookup {
if (await Directory(dataPath).exists()) {
await _indexDir(dataPath, recursive: false);
}
} catch (e) {
} catch (e, s) {
print("Error indexing WAI files:");
print(e);
print("$e\n$s");
}

loadingCompleter!.complete();
Expand Down
4 changes: 2 additions & 2 deletions lib/fileTypeUtils/audio/audioModsChangesUndo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ Future<void> revertAllAudioMods(String waiPath) async {
await File(changedFile).delete();
await File(backupPath).rename(changedFile);
restoreCount++;
} catch (e) {
} catch (e, s) {
messageLog.add("Failed to restore $changedFile");
print(e);
print("$e\n$s");
warningCount++;
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/fileTypeUtils/audio/modInstaller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:archive/archive_io.dart';
import 'package:file_picker/file_picker.dart';
import 'package:path/path.dart';

import '../../stateManagement/events/statusInfo.dart';
import '../../stateManagement/preferencesData.dart';
import '../../utils/utils.dart';
import '../utils/ByteDataWrapper.dart';
Expand Down Expand Up @@ -64,7 +63,6 @@ Future<void> installMod(String waiPath) async {
}

showToast("Mod installed successfully :)");
messageLog.add("Mod installed successfully :)");
} catch (e) {
// restore original files
for (var file in changedFiles) {
Expand Down
3 changes: 2 additions & 1 deletion lib/fileTypeUtils/dat/datExtractor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ Stream<ExtractedInnerFile> extractDatFilesAsStream(String datPath) async* {
bytes.makeSubView(fileSizes[i])
);
}
} catch (e) {
} catch (e, s) {
print("Error while extracting dat files from $datPath");
print("$e\n$s");
return;
}
}
4 changes: 2 additions & 2 deletions lib/fileTypeUtils/textures/fontAtlasGenerator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Future<FontAtlasGenResult> runFontAtlasGenerator(FontAtlasGenCliOptions options)
try {
var atlasInfoJson = jsonDecode(await stdout);
return FontAtlasGenResult.fromJson(atlasInfoJson);
} catch (e) {
} catch (e, s) {
showToast("Font atlas generator failed");
print(e);
print("$e\n$s");
print(await stdout);
print(await stderr);
throw Exception("Font atlas generator failed");
Expand Down
4 changes: 2 additions & 2 deletions lib/stateManagement/beforeExitCleanup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Future<bool> beforeExitConfirmation() async {

try {
await beforeExitCleanup();
} catch (e) {
print(e);
} catch (e, s) {
print("$e\n$s");
}

return true;
Expand Down
6 changes: 3 additions & 3 deletions lib/stateManagement/hierarchy/FileHierarchy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class OpenHierarchyManager with HasUuid, Undoable, HierarchyEntryBase implements
children.addListener(() => filteredTreeIsDirty.value = true);
_onSearchChangedThrottled = debounce(() => filteredTreeIsDirty.value = true, 500);
search.addListener(() {
var (overThreshold, count) = hasOverXChildren(500*1000);
var (overThreshold, _) = hasOverXChildren(500*1000);
if (overThreshold)
_onSearchChangedThrottled();
else
Expand Down Expand Up @@ -199,8 +199,8 @@ class OpenHierarchyManager with HasUuid, Undoable, HierarchyEntryBase implements
else {
try {
datFilePaths = await getDatFileList(datExtractDir);
} catch (e) {
print(e);
} catch (e, s) {
print("$e\n$s");
}
//check if extracted folder actually contains all dat files
if (datFilePaths == null || await Future.any(datFilePaths.map((name) async => !await File(name).exists()))) {
Expand Down
3 changes: 2 additions & 1 deletion lib/stateManagement/openFiles/filesAreaManager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ class FilesAreaManager with HasUuid, Undoable implements Disposable {
await Future.wait(
files.where((file) => file.hasUnsavedChanges.value)
.map((file) => file.save()));
} catch (e) {
} catch (e, s) {
print("Error while saving all files");
print("$e\n$s");
rethrow;
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/stateManagement/openFiles/openFilesManager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ class OpenFilesAreasManager with HasUuid, Undoable implements Disposable {
]);
onSaveAll.notifyListeners();
await processChangedFiles();
} catch (e) {
} catch (e, s) {
showToast("Error saving files");
print("$e\n$s");
rethrow;
} finally {
isLoadingStatus.popIsLoading();
Expand Down
3 changes: 2 additions & 1 deletion lib/stateManagement/openFiles/types/FtbFileData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ class FtbFileData extends OpenFileData {
var bytes = await ByteDataWrapper.fromFile(fontPath);
var ttf = TtfFile.read(bytes);
fontChars = ttf.allChars();
} catch (e) {
} catch (e, s) {
showToast("Failed to read font file");
print("$e\n$s");
rethrow;
}
ftbData!.pendingNewChars.clear();
Expand Down
4 changes: 2 additions & 2 deletions lib/stateManagement/openFiles/types/McdFileData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ class McdData extends _McdFilePart {
try {
textureSize = await getImageSize(wtpPath);
}
catch (e) {
catch (e, s) {
showToast("Unable to read ${basename(wtpPath)} file!");
print(e);
print("$e\n$s");
throw Exception("Unable to read $wtpPath");
}

Expand Down
4 changes: 2 additions & 2 deletions lib/stateManagement/openFiles/types/TextFileData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class TextFileData extends OpenFileData {
loadingState.value = LoadingState.loading;
try {
text.value = await File(path).readAsString();
} catch (e) {
} catch (e, s) {
text.value = "[Error loading file]";
print(e);
print("$e\n$s");
}
await super.load();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/assetDirFinder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ Future<bool> checkPythonVersion(String cmd) async {
return false;

return true;
} catch (e) {
} catch (e, s) {
print("Error checking python version");
print(e);
print("$e\n$s");
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/filesView/types/fonts/fontOverridesApply.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class FontOverridesApplyButton extends StatelessWidget {
.where((file) => file is McdFileData || file is FtbFileData);
await Future.wait(savableFiles.map((f) => f.save()));
messageLog.add("Done :>");
} catch (e) {
} catch (e, s) {
messageLog.add("Error :/");
print(e);
print("$e\n$s");
} finally {
await processChangedFiles();
isLoadingStatus.popIsLoading();
Expand Down
9 changes: 4 additions & 5 deletions lib/widgets/filesView/types/fonts/mcdEditor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ class _McdEditorState extends ChangeNotifierState<McdEditor> {
children: widget.file.loadingState.value == LoadingState.loaded ? [
_McdEditorBody(file: widget.file, mcd: widget.file.mcdData!),
FontsManager(mcd: widget.file.mcdData!),
if (widget.file.mcdData!.textureWtpPath != null)
McdFontDebugger(
texturePath: widget.file.mcdData!.textureWtpPath!.value,
fonts: widget.file.mcdData!.usedFonts.values.toList(),
),
McdFontDebugger(
texturePath: widget.file.mcdData!.textureWtpPath.value,
fonts: widget.file.mcdData!.usedFonts.values.toList(),
),
] : List.filled(3, loadingIndicator),
),
),
Expand Down
8 changes: 4 additions & 4 deletions lib/widgets/filesView/types/genericTable/tableExporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ Future<void> loadTableFromJson(CustomTableConfig tableConfig) async {
for (int i = 0; i < table.length; i++) {
tableConfig.updateRowWith(i, table[i]);
}
} catch (e) {
print(e);
} catch (e, s) {
print("$e\n$s");
showToast("Failed to load table from JSON");
}
}
Expand All @@ -105,8 +105,8 @@ Future<void> loadTableFromCsv(CustomTableConfig tableConfig) async {
for (int i = 0; i < table.length; i++) {
tableConfig.updateRowWith(i, table[i]);
}
} catch (e) {
print(e);
} catch (e, s) {
print("$e\n$s");
showToast("Failed to load table from CSV");
}
}

0 comments on commit 5bd7249

Please sign in to comment.