mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
## Summary of Changes
**1. Created `v2/internal/frontend/desktop/linux/panic_handler.go`**
- Ported the panic recovery logic from v3
- Includes `getStackTrace()` function for generating readable stack traces
- `handlePanic()` function that recovers from panics and either calls the custom handler or logs the error
**2. Added to `v2/pkg/options/options.go`**
- Added `PanicDetails` struct with `StackTrace`, `Error`, `Time`, and `FullStackTrace` fields
- Added `PanicHandler` type: `func(*PanicDetails)`
- Added `PanicHandler` field to the `App` struct with documentation
**3. Modified `v2/internal/frontend/desktop/linux/frontend.go`**
- Added `defer handlePanic(f.frontendOptions.PanicHandler, f.logger)` to the goroutine in `processMessage()` (line 468)
## Usage Example
Users can now configure a custom panic handler in their v2 Wails application:
```go
app := wails.Run(&options.App{
Title: "My App",
// ... other options
PanicHandler: func(details *options.PanicDetails) {
// Custom panic handling logic
log.Printf("Panic occurred at %v: %v\n%s",
details.Time,
details.Error,
details.StackTrace)
// Could show error dialog, send to error tracking service, etc.
},
})
```
If no `PanicHandler` is set, panics will be logged via the application logger and the application will continue running instead of crashing with a signal handler error.
|
||
|---|---|---|
| .. | ||
| application | ||
| assetserver | ||
| buildassets | ||
| clilogger | ||
| commands | ||
| git | ||
| logger | ||
| mac | ||
| menu | ||
| options | ||
| runtime | ||
| templates | ||