try catch

This commit is contained in:
Tommy Parnell
2022-03-17 23:23:10 -04:00
parent 8059112810
commit aeb26aaccb

View File

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