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

753 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
TryCatch trycatch errors.go#L335 core error-handling https://go.dev/play/p/PnOON-EqBiU
core#error-handling#trycatch
core#error-handling#validate
core#error-handling#mustx
core#error-handling#tryx
core#error-handling#tryorx
core#error-handling#trywitherrorvalue
core#error-handling#trycatchwitherrorvalue
core#error-handling#errorsas
core#error-handling#assert
50
func TryCatch(callback func() error, catch func())

Calls the catch function when the callback errors or panics.

caught := false
lo.TryCatch(func() error { panic("error") }, func() { caught = true })
// caught == true