Skip to content

Commit

Permalink
GdriveRenewWebhook: fix error handling (#4142)
Browse files Browse the repository at this point in the history
  • Loading branch information
spolu authored Mar 5, 2024
1 parent 2586ca0 commit f02f628
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion connectors/src/connectors/google_drive/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ export async function registerWebhook(
};
return new Ok(result);
} else {
return new Err(new HTTPError(await res.text(), res.status));
let errorMsg = await res.text();
try {
// Gdrive returns JSON errors, attempt to parse it.
const error = JSON.parse(errorMsg);
errorMsg = error.error.message;
} catch (e) {
// Keep the raw text as error message
}
return new Err(new HTTPError(errorMsg, res.status));
}
}

Expand Down

0 comments on commit f02f628

Please sign in to comment.