try catch
This commit is contained in:
@@ -28,6 +28,7 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe
|
||||
}
|
||||
return
|
||||
}
|
||||
try {
|
||||
const highlighted = Prism.highlight(data.replace(/```[a-zA-Z]*/m, '').replace('```', ''), Prism.languages[lang], lang)
|
||||
|
||||
// remove any backticks and the language
|
||||
@@ -36,8 +37,15 @@ const httpTrigger: AzureFunction = async function (context: Context, req: HttpRe
|
||||
status: 200,
|
||||
body: `<pre class="language-${lang}"><code class="language-${lang}">${highlightedCleaned}</code></pre>`
|
||||
}
|
||||
} catch {
|
||||
context.res = {
|
||||
status: 200,
|
||||
body: req.rawBody
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default httpTrigger;
|
||||
Reference in New Issue
Block a user