MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / catch_panic_unwind_safe

Function catch_panic_unwind_safe

src/util.rs:166–173  ·  view source on GitHub ↗

Convenience wrapper around [`catch_panic`] for closures that capture `&self` or other non-[`UnwindSafe`] references. Wraps `f` in [`AssertUnwindSafe`] before forwarding to [`catch_panic`]. This is safe in our context because a panic during LSP handling never leaves shared state in an inconsistent state (the worst case is a stale cache entry).

(
    label: &str,
    uri: &str,
    position: Option<Position>,
    f: impl FnOnce() -> T,
)

Source from the content-addressed store, hash-verified

164/// during LSP handling never leaves shared state in an inconsistent
165/// state (the worst case is a stale cache entry).
166pub(crate) fn catch_panic_unwind_safe<T>(
167 label: &str,
168 uri: &str,
169 position: Option<Position>,
170 f: impl FnOnce() -> T,
171) -> Option<T> {
172 catch_panic(label, uri, position, AssertUnwindSafe(f))
173}
174
175/// Convert a filesystem path to a properly percent-encoded `file://` URI string.
176///

Callers 4

with_file_contentMethod · 0.85
update_astMethod · 0.85
handle_hoverMethod · 0.85

Calls 1

catch_panicFunction · 0.85

Tested by

no test coverage detected