summaryrefslogtreecommitdiff
path: root/vendor/github.com/sourcegraph/conc/panics/try.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-01-17 14:54:30 +0000
committerLibravatar GitHub <noreply@github.com>2024-01-17 14:54:30 +0000
commit906639ad7eb92e9d631599f78979908930e59c84 (patch)
treedfef6d0a5ba47c49c214e4537a89dee6ad528df8 /vendor/github.com/sourcegraph/conc/panics/try.go
parent[bugfix] Better Postgres search case insensitivity (#2526) (diff)
downloadgotosocial-906639ad7eb92e9d631599f78979908930e59c84.tar.xz
[chore] update viper version (#2539)
* update viper version * removes our last uses of the slice package * fix tests
Diffstat (limited to 'vendor/github.com/sourcegraph/conc/panics/try.go')
-rw-r--r--vendor/github.com/sourcegraph/conc/panics/try.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/vendor/github.com/sourcegraph/conc/panics/try.go b/vendor/github.com/sourcegraph/conc/panics/try.go
new file mode 100644
index 000000000..4ded92a1c
--- /dev/null
+++ b/vendor/github.com/sourcegraph/conc/panics/try.go
@@ -0,0 +1,11 @@
+package panics
+
+// Try executes f, catching and returning any panic it might spawn.
+//
+// The recovered panic can be propagated with panic(), or handled as a normal error with
+// (*panics.Recovered).AsError().
+func Try(f func()) *Recovered {
+ var c Catcher
+ c.Try(f)
+ return c.Recovered()
+}