Added description and fixed issue with colors (#686)

This commit is contained in:
Ricardo Espinoza
2020-06-20 11:51:11 -04:00
committed by GitHub
parent 5db2ce2924
commit 6d7368d723
3 changed files with 30 additions and 6 deletions

View File

@@ -33,9 +33,15 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options);
} catch (error) {
if (error.response && error.response.body && error.response.body.message) {
if (error.response && error.response.body && error.response.body.error) {
let errors = error.response.body.error.errors;
errors = errors.map((e: IDataObject) => e.message);
// Try to return the error prettier
throw new Error(`Google Calendar error response [${error.statusCode}]: ${error.response.body.message}`);
throw new Error(
`Google Calendar error response [${error.statusCode}]: ${errors.join('|')}`
);
}
throw error;
}