diff --git a/exp/pkg/application/errors.go b/exp/pkg/application/errors.go new file mode 100644 index 000000000..747142328 --- /dev/null +++ b/exp/pkg/application/errors.go @@ -0,0 +1,16 @@ +package application + +import ( + "fmt" + "os" +) + +func Fatal(message string, args ...interface{}) { + println("*********************** FATAL ***********************") + println("There has been a catastrophic failure in your application.") + println("Please report this error at https://github.com/wailsapp/wails/issues") + println("******************** Error Details ******************") + println(fmt.Sprintf(message, args...)) + println("*********************** FATAL ***********************") + os.Exit(1) +} diff --git a/exp/pkg/application/mainthread.go b/exp/pkg/application/mainthread.go index c91fec8b0..16068c39b 100644 --- a/exp/pkg/application/mainthread.go +++ b/exp/pkg/application/mainthread.go @@ -7,7 +7,6 @@ extern void dispatch(unsigned int id); */ import "C" import ( - "os" "sync" ) @@ -22,7 +21,7 @@ func generateFunctionStoreID() uint { } startID++ if startID == 0 { - panic("Too many functions stored") + Fatal("Too many functions have been dispatched to the main thread") } } } @@ -41,8 +40,7 @@ func dispatchCallback(callbackID C.uint) { id := uint(callbackID) fn := mainThreadFuntionStore[id] if fn == nil { - println("***** dispatchCallback called with invalid id: ", id) - os.Exit(1) + Fatal("dispatchCallback called with invalid id: ", id) } delete(mainThreadFuntionStore, id) mainThreadFuntionStoreLock.RUnlock()