Skip to content

Commit 70a0fba

Browse files
authored
Restore Catch Exception Logic (#424)
In any case, we should not crash at the user end This commit reverts the previous FileException only error handling And add runtime error dump to let users know that they should report to developers
1 parent c0fe90c commit 70a0fba

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

source/creator/package.d

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ bool incOpenProject(string path) {
231231
*/
232232
bool incOpenProject(string mainPath, string backupPath) {
233233
import std.path : setExtension, baseName;
234-
import std.file : FileException;
235234

236235
incClearImguiData();
237236

@@ -244,9 +243,15 @@ bool incOpenProject(string mainPath, string backupPath) {
244243
} else {
245244
puppet = inLoadPuppet!ExPuppet(mainPath);
246245
}
247-
} catch (FileException ex) {
248-
// Also handle NFS or I/O errors
249-
incDialog(__("Error"), ex.msg);
246+
} catch (Exception ex) {
247+
// for user, we should show a dialog and dump the thrown stack
248+
import std.file : write;
249+
import creator.utils.crashdump;
250+
string path = genCrashDumpPath("inochi-creator-runtime-error");
251+
write(path, genCrashDump(ex));
252+
253+
// show dialog
254+
incDialog(__("Error"), ex.msg ~ "\n\n" ~ _("Please report this file to the developers:\n\n%s").format(path));
250255
return false;
251256
}
252257

source/creator/utils/crashdump.d

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ string getCrashDumpDir() {
5353
else return expandTilde("~");
5454
}
5555

56-
56+
string genCrashDumpPath(string filename) {
57+
import std.datetime;
58+
return buildPath(getCrashDumpDir(), filename ~ "-" ~ Clock.currTime.toISOString() ~ ".txt");
59+
}
5760

5861
void crashdump(T...)(Throwable throwable, T state) {
5962

6063
// Write crash dump to disk
61-
write(buildPath(getCrashDumpDir(), "inochi-creator-crashdump.txt"), genCrashDump!T(throwable, state));
64+
write(genCrashDumpPath("inochi-creator-crashdump"), genCrashDump!T(throwable, state));
6265

6366
// Use appropriate system method to notify user where crash dump is.
6467
version(OSX) writeln(_("\n\n\n=== Inochi Creator has crashed ===\nPlease send us the inochi-creator-crashdump.txt file in ~/Library/Logs\nAttach the file as a git issue @ https://github.com/Inochi2D/inochi-creator/issues"));

0 commit comments

Comments
 (0)