Files
lo/docs/data/core-trycatchwitherrorvalue.md
T
2025-10-06 17:15:49 +02:00

843 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
TryCatchWithErrorValue trycatchwitherrorvalue errors.go#L343 core error-handling https://go.dev/play/p/8Pc9gwX_GZO
core#error-handling#trycatchwitherrorvalue
core#error-handling#validate
core#error-handling#mustx
core#error-handling#tryx
core#error-handling#tryorx
core#error-handling#trywitherrorvalue
core#error-handling#trycatch
core#error-handling#errorsas
core#error-handling#assert
60
func TryCatchWithErrorValue(callback func() error, catch func(any))

Calls the catch function with the error value when the callback errors or panics.

lo.TryCatchWithErrorValue(
    func() error {
        panic("error")
    },
    func(val any) {
        fmt.Println(val)
    },
)