This commit is contained in:
Mike Schwörer 2023-04-26 11:35:28 +02:00
parent 0aa6310971
commit a445e6f623
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -12,7 +12,7 @@ func (p PanicWrappedErr) ReoveredObj() any {
return p.panic
}
func runPanicSafe(fn func()) (err error) {
func RunPanicSafe(fn func()) (err error) {
defer func() {
if rec := recover(); rec != nil {
err = PanicWrappedErr{panic: rec}
@ -24,7 +24,7 @@ func runPanicSafe(fn func()) (err error) {
return nil
}
func runPanicSafeR1(fn func() error) (err error) {
func RunPanicSafeR1(fn func() error) (err error) {
defer func() {
if rec := recover(); rec != nil {
err = PanicWrappedErr{panic: rec}
@ -34,7 +34,7 @@ func runPanicSafeR1(fn func() error) (err error) {
return fn()
}
func runPanicSafeR2[T1 any](fn func() (T1, error)) (r1 T1, err error) {
func RunPanicSafeR2[T1 any](fn func() (T1, error)) (r1 T1, err error) {
defer func() {
if rec := recover(); rec != nil {
r1 = *new(T1)
@ -45,7 +45,7 @@ func runPanicSafeR2[T1 any](fn func() (T1, error)) (r1 T1, err error) {
return fn()
}
func runPanicSafeR3[T1 any, T2 any](fn func() (T1, T2, error)) (r1 T1, r2 T2, err error) {
func RunPanicSafeR3[T1 any, T2 any](fn func() (T1, T2, error)) (r1 T1, r2 T2, err error) {
defer func() {
if rec := recover(); rec != nil {
r1 = *new(T1)
@ -57,7 +57,7 @@ func runPanicSafeR3[T1 any, T2 any](fn func() (T1, T2, error)) (r1 T1, r2 T2, er
return fn()
}
func runPanicSafeR4[T1 any, T2 any, T3 any](fn func() (T1, T2, T3, error)) (r1 T1, r2 T2, r3 T3, err error) {
func RunPanicSafeR4[T1 any, T2 any, T3 any](fn func() (T1, T2, T3, error)) (r1 T1, r2 T2, r3 T3, err error) {
defer func() {
if rec := recover(); rec != nil {
r1 = *new(T1)