diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/actions/AzureSignInAction.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/actions/AzureSignInAction.java index 4258ecb9f4e..e099c1432b8 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/actions/AzureSignInAction.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/actions/AzureSignInAction.java @@ -31,7 +31,6 @@ import com.microsoft.azuretools.authmanage.AuthMethod; import com.microsoft.azuretools.authmanage.AuthMethodManager; import com.microsoft.azuretools.authmanage.models.AuthMethodDetails; -import com.microsoft.azuretools.ijidea.ui.ErrorWindow; import com.microsoft.azuretools.ijidea.ui.SignInWindow; import com.microsoft.azuretools.ijidea.utility.AzureAnAction; import com.microsoft.azuretools.telemetry.TelemetryConstants; @@ -122,25 +121,20 @@ private static String getSignOutWarningMessage(@NotNull AuthMethodManager authMe public static void onAzureSignIn(Project project) { JFrame frame = WindowManager.getInstance().getFrame(project); - try { - AuthMethodManager authMethodManager = AuthMethodManager.getInstance(); - boolean isSignIn = authMethodManager.isSignedIn(); - if (isSignIn) { - boolean res = DefaultLoader.getUIHelper().showYesNoDialog(frame.getRootPane(), - getSignOutWarningMessage(authMethodManager), - "Azure Sign Out", - new ImageIcon("icons/azure.png")); - if (res) { - EventUtil.executeWithLog(ACCOUNT, SIGNOUT, (operation) -> { - authMethodManager.signOut(); - }); - } - } else { - doSignIn(authMethodManager, project); + AuthMethodManager authMethodManager = AuthMethodManager.getInstance(); + boolean isSignIn = authMethodManager.isSignedIn(); + if (isSignIn) { + boolean res = DefaultLoader.getUIHelper().showYesNoDialog(frame.getRootPane(), + getSignOutWarningMessage(authMethodManager), + "Azure Sign Out", + new ImageIcon("icons/azure.png")); + if (res) { + EventUtil.executeWithLog(ACCOUNT, SIGNOUT, (operation) -> { + authMethodManager.signOut(); + }); } - } catch (Exception ex) { - ex.printStackTrace(); - ErrorWindow.show(project, ex.getMessage(), "AzureSignIn Action Error"); + } else { + doSignIn(authMethodManager, project); } } diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/ui/SignInWindow.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/ui/SignInWindow.java index 80a4092b59d..c7458ba8262 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/ui/SignInWindow.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azuretools/ijidea/ui/SignInWindow.java @@ -98,7 +98,7 @@ private SignInWindow(AuthMethodDetails authMethodDetails, Project project) { setOKButtonText("Sign in"); this.authMethodDetails = authMethodDetails; - authFileTextField.setText(authMethodDetails.getCredFilePath()); + authFileTextField.setText(authMethodDetails == null ? null : authMethodDetails.getCredFilePath()); automatedRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -223,7 +223,7 @@ protected void init() { AzureTokenWrapper tokenWrapper = null; try { tokenWrapper = AzureAuthHelper.getAzureCLICredential(null); - } catch (IOException e) { + } catch (IOException | RuntimeException e) { // swallow exception while getting azure cli credential } if (tokenWrapper != null) { diff --git a/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/function/AzureFunctionMvpModel.java b/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/function/AzureFunctionMvpModel.java index 9c160b7f246..63d35def552 100644 --- a/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/function/AzureFunctionMvpModel.java +++ b/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/function/AzureFunctionMvpModel.java @@ -44,7 +44,6 @@ public class AzureFunctionMvpModel { public static final PricingTier CONSUMPTION_PRICING_TIER = new PricingTier("Consumption", ""); - private static final String CANNOT_GET_FUNCTION_APP_WITH_ID = "Cannot get Function App with ID: "; private final Map>> subscriptionIdToFunctionApps; private AzureFunctionMvpModel() { @@ -64,8 +63,8 @@ public static AzureFunctionMvpModel getInstance() { public FunctionApp getFunctionById(String sid, String id) throws AzureToolkitRuntimeException { final FunctionApp app = getFunctionAppsClient(sid).getById(id); if (Objects.isNull(app)) { - final String error = String.format("Cannot find FunctionApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid); - final String action = String.format("Confirm if the FunctionApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id)); + final String error = String.format("cannot find FunctionApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid); + final String action = String.format("confirm if the FunctionApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id)); throw new AzureToolkitRuntimeException(error, action); } return app; @@ -229,12 +228,9 @@ public static boolean isApplicationLogEnabled(WebAppBase webAppBase) { return false; } final ApplicationLogsConfig applicationLogsConfig = config.inner().applicationLogs(); - return (applicationLogsConfig.fileSystem() != null - && applicationLogsConfig.fileSystem().level() != LogLevel.OFF) || - (applicationLogsConfig.azureBlobStorage() != null - && applicationLogsConfig.azureBlobStorage().level() != LogLevel.OFF) || - (applicationLogsConfig.azureTableStorage() != null - && applicationLogsConfig.azureTableStorage().level() != LogLevel.OFF); + return (applicationLogsConfig.fileSystem() != null && applicationLogsConfig.fileSystem().level() != LogLevel.OFF) || + (applicationLogsConfig.azureBlobStorage() != null && applicationLogsConfig.azureBlobStorage().level() != LogLevel.OFF) || + (applicationLogsConfig.azureTableStorage() != null && applicationLogsConfig.azureTableStorage().level() != LogLevel.OFF); } @AzureOperation( diff --git a/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/webapp/AzureWebAppMvpModel.java b/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/webapp/AzureWebAppMvpModel.java index d6530f201c4..769d7c9bdf7 100644 --- a/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/webapp/AzureWebAppMvpModel.java +++ b/Utils/azuretools-core/src/com/microsoft/azuretools/core/mvp/model/webapp/AzureWebAppMvpModel.java @@ -87,8 +87,8 @@ public static AzureWebAppMvpModel getInstance() { public WebApp getWebAppById(String sid, String id) throws AzureToolkitRuntimeException { final WebApp webapp = this.getNullableWebAppById(sid, id); if (Objects.isNull(webapp)) { - final String error = String.format("Cannot find WebApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid); - final String action = String.format("Confirm if the WebApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id)); + final String error = String.format("cannot find WebApp[%s] in subscription[%s]", ResourceUtils.nameFromResourceId(id), sid); + final String action = String.format("confirm if the WebApp[id=%s] still exists", ResourceUtils.nameFromResourceId(id)); throw new AzureToolkitRuntimeException(error, action); } return webapp;