mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Refactor error handling part 2 (#313)
This commit is contained in:
@@ -5,6 +5,7 @@ import { AuthType } from "../AuthType";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { configContext, Platform } from "../ConfigContext";
|
||||
import { userContext } from "../UserContext";
|
||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
||||
|
||||
export function getAuthorizationHeader(): ViewModels.AuthorizationTokenHeaderMetadata {
|
||||
if (window.authType === AuthType.EncryptedToken) {
|
||||
@@ -28,7 +29,7 @@ export async function getArcadiaAuthToken(
|
||||
const token = await AuthHeadersUtil.getAccessToken(arcadiaEndpoint, tenantId);
|
||||
return token;
|
||||
} catch (error) {
|
||||
Logger.logError(error, "AuthorizationUtils/getArcadiaAuthToken");
|
||||
Logger.logError(getErrorMessage(error), "AuthorizationUtils/getArcadiaAuthToken");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IGalleryItem, JunoClient } from "../Juno/JunoClient";
|
||||
import * as NotificationConsoleUtils from "./NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import {
|
||||
GalleryTab,
|
||||
SortBy,
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
import Explorer from "../Explorer/Explorer";
|
||||
import { IChoiceGroupOption, IChoiceGroupProps } from "office-ui-fabric-react";
|
||||
import { TextFieldProps } from "../Explorer/Controls/DialogReactComponent/DialogComponent";
|
||||
import { handleError } from "../Common/ErrorHandlingUtils";
|
||||
|
||||
const defaultSelectedAbuseCategory = "Other";
|
||||
const abuseCategories: IChoiceGroupOption[] = [
|
||||
@@ -122,9 +122,11 @@ export function reportAbuse(
|
||||
);
|
||||
onComplete(response.data);
|
||||
} catch (error) {
|
||||
const message = `Failed to submit report on ${data.name} violating code of conduct: ${error}`;
|
||||
Logger.logError(message, "GalleryUtils/reportAbuse");
|
||||
NotificationConsoleUtils.logConsoleInfo(message);
|
||||
handleError(
|
||||
error,
|
||||
"GalleryUtils/reportAbuse",
|
||||
`Failed to submit report on ${data.name} violating code of conduct`
|
||||
);
|
||||
}
|
||||
|
||||
clearSubmitReportNotification();
|
||||
@@ -185,9 +187,7 @@ export function downloadItem(
|
||||
onComplete(increaseDownloadResponse.data);
|
||||
}
|
||||
} catch (error) {
|
||||
const message = `Failed to download ${data.name}: ${error}`;
|
||||
Logger.logError(message, "GalleryUtils/downloadItem");
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, message);
|
||||
handleError(error, "GalleryUtils/downloadItem", `Failed to download ${data.name}`);
|
||||
}
|
||||
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(notificationId);
|
||||
@@ -212,9 +212,7 @@ export async function favoriteItem(
|
||||
|
||||
onComplete(response.data);
|
||||
} catch (error) {
|
||||
const message = `Failed to favorite ${data.name}: ${error}`;
|
||||
Logger.logError(message, "GalleryUtils/favoriteItem");
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, message);
|
||||
handleError(error, "GalleryUtils/favoriteItem", `Failed to favorite ${data.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,9 +232,7 @@ export async function unfavoriteItem(
|
||||
|
||||
onComplete(response.data);
|
||||
} catch (error) {
|
||||
const message = `Failed to unfavorite ${data.name}: ${error}`;
|
||||
Logger.logError(message, "GalleryUtils/unfavoriteItem");
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, message);
|
||||
handleError(error, "GalleryUtils/unfavoriteItem", `Failed to unfavorite ${data.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,9 +264,7 @@ export function deleteItem(
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Info, `Successfully removed ${name} from gallery`);
|
||||
onComplete(response.data);
|
||||
} catch (error) {
|
||||
const message = `Failed to remove ${name} from gallery: ${error}`;
|
||||
Logger.logError(message, "GalleryUtils/deleteItem");
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, message);
|
||||
handleError(error, "GalleryUtils/deleteItem", `Failed to remove ${name} from gallery`);
|
||||
}
|
||||
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(notificationId);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
||||
|
||||
interface KernelConnectionMetadata {
|
||||
name: string;
|
||||
@@ -78,13 +79,13 @@ export class NotebookConfigurationUtils {
|
||||
if (!response.ok) {
|
||||
const responseMessage = await response.json();
|
||||
Logger.logError(
|
||||
JSON.stringify(responseMessage),
|
||||
getErrorMessage(responseMessage),
|
||||
"NotebookConfigurationUtils/configureServiceEndpoints",
|
||||
response.status
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.logError(error, "NotebookConfigurationUtils/configureServiceEndpoints");
|
||||
Logger.logError(getErrorMessage(error), "NotebookConfigurationUtils/configureServiceEndpoints");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user