i dont even know what this PR is supposed to be about anymore, everyone lost the plot somewhere in the middle of act 2 #74

Open
Guzio wants to merge 128 commits from Guzio/out-of-your-element:mergable-fr-fr into main
Showing only changes of commit ea94dfe6b9 - Show all commits

Fighting the demons of my past

TECHNICALLY, I was asked to remove it. But now that I know that @template is a thing that exists in JSDoc (which was the one missing ingredient the last time), I think I can get this to be good enough that removal won't even be necessary, and now it just looks like regular, sane documentation (not the any-schizopost like last time).
Guzio 2026-04-26 14:12:13 +00:00

View file

@ -158,13 +158,17 @@ async function sendError(roomID, source, type, e, payload) {
}
/**
* @param {string} type
* @param {(event: Ty.Event.Outer<any> & {type: any, redacts:any, state_key:any}, ...args: any)=>any} fn
* Wraps the function with an automated error catching and reporting mechanism
* @template {Ty.Event.Outer<any>} EVENT The event that the wrapped function processes, its first argument.
* @template {[]} ARGS Other arguments of the wrapped function
* @template RETURNS The output of the wrapped function
* @param {string} type Type of the event, during the processing of which the error may occur.
* @param {(event: EVENT, ...args: ARGS)=>RETURNS|Promise<RETURNS>} fn Function to wrap
* @returns {(event: EVENT, ...args: ARGS)=>Promise<RETURNS|undefined>} Wrapped function
*/
function guard(type, fn) {
return async function(/** @type {Ty.Event.Outer<any>} */ event, /** @type {any} */ ...args) {
return async function(event, ...args) {
try {
// @ts-ignore
return await fn(event, ...args)
} catch (e) {
await sendError(event.room_id, "Matrix", type, e, event)