Add Fatal()

This commit is contained in:
Lea Anthony 2022-12-11 20:05:00 +11:00
commit f38c6c6d1c
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
2 changed files with 18 additions and 4 deletions

View file

@ -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)
}

View file

@ -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()