Scheduling infrastructure for absolutely everyone.
fix: correct impossible logical condition in Office365 calendar error handling #23151 (#23185)
Morganae8e63371661
diff --git a/packages/app-store/office365calendar/lib/CalendarService.ts b/packages/app-store/office365calendar/lib/CalendarService.tsindex 04626103f4c..cb9b6c18a42 100644--- a/packages/app-store/office365calendar/lib/CalendarService.ts+++ b/packages/app-store/office365calendar/lib/CalendarService.ts@@ -661,22 +661,30 @@ export default class Office365CalendarService implements Calendar {);};- private handleErrorJsonOffice365Calendar = <Type>(response: Response): Promise<Type | string> => {+ private async handleErrorJsonOffice365Calendar<Type>(response: Response): Promise<Type | string> {if (response.headers.get("content-encoding") === "gzip") {return response.text();}if (response.status === 204) {- return new Promise((resolve) => resolve({} as Type));+ return {} as Type;}- if (!response.ok && response.status < 200 && response.status >= 300) {- response.json().then(console.log);- throw Error(response.statusText);+ if (!response.ok) {+ let errorBody: string | object;+ try {+ errorBody = await response.json();+ } catch (e) {+ errorBody = await response.text();+ }+ this.log.error(+ `handleErrorJsonOffice365Calendar: Office365 API request failed with status ${response.status}`,+ errorBody+ );}return response.json();- };+ }async getMainTimeZone(): Promise<string> {try {