mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
fix(api): print errors without stacktrace
This commit is contained in:
parent
9e0244bc24
commit
d129eaf912
|
@ -36,13 +36,19 @@ module.exports = async function (context, req) {
|
|||
|
||||
redirect(context, segment, tokens, '');
|
||||
} catch (error) {
|
||||
if (!error.stack) {
|
||||
redirect(context, segment, tokens, toBase64(error));
|
||||
return;
|
||||
}
|
||||
context.log(`Error: ${error.stack}`);
|
||||
let buff = Buffer.from(error.stack);
|
||||
let message = buff.toString('base64');
|
||||
redirect(context, segment, tokens, message);
|
||||
redirect(context, segment, tokens, toBase64(error.stack));
|
||||
}
|
||||
}
|
||||
|
||||
function toBase64(str) {
|
||||
return Buffer.from(str).toString('base64');
|
||||
}
|
||||
|
||||
function redirect(context, segment, tokens, error) {
|
||||
const url = `${process.env['DOCS_LOCATION']}/docs/auth?segment=${segment}&access_token=${tokens.access_token}&refresh_token=${tokens.refresh_token}&expires_in=${tokens.expires_in}&error=${error}`;
|
||||
context.res = {
|
||||
|
|
Loading…
Reference in a new issue