function spreadsheetErrorHandler<T extends (...args: any[]) => any>(
func: T
): T {
return <T>function (...args: any[]) {
try {
return func(...args)
} catch (err) {
if (
err instanceof SpreadsheetHelper.SpreadsheetHelperError &&
err.range
) {
throw new CellValueError(err.message, err.range)
}
throw err
}
}
}-
-
Save LarsBuur/4a59281a4213d91bc1b7913cfcef0adf to your computer and use it in GitHub Desktop.
[TypeScript Tips] #typescript #tips #cheatsheet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment