Improve error message handling (#497)

- Add special handling for token expired errors so they send with a clear flag that'll allow clients to take action on this case
- Send error message instead of callstack for all messages, and ensure all resource manager paths send back inner exceptions so users can understand the true root cause.
This commit is contained in:
Kevin Cunnane
2017-10-13 17:48:25 -07:00
committed by GitHub
parent b416951414
commit 0c7f559315
17 changed files with 381 additions and 275 deletions

View File

@@ -27,7 +27,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
Keys.Culture = value;
}
}
public static string FailedToGetAzureDatabasesErrorMessage
{
@@ -35,7 +35,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FailedToGetAzureDatabasesErrorMessage);
}
}
}
public static string FailedToGetAzureSubscriptionsErrorMessage
{
@@ -43,7 +43,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FailedToGetAzureSubscriptionsErrorMessage);
}
}
}
public static string FailedToGetAzureResourceGroupsErrorMessage
{
@@ -51,7 +51,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FailedToGetAzureResourceGroupsErrorMessage);
}
}
}
public static string FailedToGetAzureSqlServersErrorMessage
{
@@ -59,7 +59,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FailedToGetAzureSqlServersErrorMessage);
}
}
}
public static string FailedToGetAzureSqlServersWithError
{
@@ -67,7 +67,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FailedToGetAzureSqlServersWithError);
}
}
}
public static string FirewallRuleCreationFailed
{
@@ -75,7 +75,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FirewallRuleCreationFailed);
}
}
}
public static string FirewallRuleCreationFailedWithError
{
@@ -83,15 +83,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.FirewallRuleCreationFailedWithError);
}
}
public static string AzureSubscriptionFailedErrorMessage
{
get
{
return Keys.GetString(Keys.AzureSubscriptionFailedErrorMessage);
}
}
}
public static string UnsupportedAuthType
{
@@ -99,7 +91,23 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return Keys.GetString(Keys.UnsupportedAuthType);
}
}
}
public static string UserNotFoundError
{
get
{
return Keys.GetString(Keys.UserNotFoundError);
}
}
public static string UserNeedsAuthenticationError
{
get
{
return Keys.GetString(Keys.UserNeedsAuthenticationError);
}
}
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Keys
@@ -107,34 +115,37 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
static ResourceManager resourceManager = new ResourceManager("Microsoft.SqlTools.ResourceProvider.DefaultImpl.Localization.SR", typeof(SR).GetTypeInfo().Assembly);
static CultureInfo _culture = null;
public const string FailedToGetAzureDatabasesErrorMessage = "FailedToGetAzureDatabasesErrorMessage";
public const string FailedToGetAzureSubscriptionsErrorMessage = "FailedToGetAzureSubscriptionsErrorMessage";
public const string FailedToGetAzureResourceGroupsErrorMessage = "FailedToGetAzureResourceGroupsErrorMessage";
public const string FailedToGetAzureSqlServersErrorMessage = "FailedToGetAzureSqlServersErrorMessage";
public const string FailedToGetAzureSqlServersWithError = "FailedToGetAzureSqlServersWithError";
public const string FirewallRuleCreationFailed = "FirewallRuleCreationFailed";
public const string FirewallRuleCreationFailedWithError = "FirewallRuleCreationFailedWithError";
public const string AzureSubscriptionFailedErrorMessage = "AzureSubscriptionFailedErrorMessage";
public const string UnsupportedAuthType = "UnsupportedAuthType";
public const string FailedToGetAzureDatabasesErrorMessage = "FailedToGetAzureDatabasesErrorMessage";
public const string FailedToGetAzureSubscriptionsErrorMessage = "FailedToGetAzureSubscriptionsErrorMessage";
public const string FailedToGetAzureResourceGroupsErrorMessage = "FailedToGetAzureResourceGroupsErrorMessage";
public const string FailedToGetAzureSqlServersErrorMessage = "FailedToGetAzureSqlServersErrorMessage";
public const string FailedToGetAzureSqlServersWithError = "FailedToGetAzureSqlServersWithError";
public const string FirewallRuleCreationFailed = "FirewallRuleCreationFailed";
public const string FirewallRuleCreationFailedWithError = "FirewallRuleCreationFailedWithError";
public const string UnsupportedAuthType = "UnsupportedAuthType";
public const string UserNotFoundError = "UserNotFoundError";
public const string UserNeedsAuthenticationError = "UserNeedsAuthenticationError";
private Keys()
{ }
@@ -155,7 +166,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
return resourceManager.GetString(key, _culture);
}
}
}
}
}
}
}

View File

@@ -120,37 +120,41 @@
<data name="FailedToGetAzureDatabasesErrorMessage" xml:space="preserve">
<value>An error occurred while getting Azure databases</value>
<comment></comment>
</data>
</data>
<data name="FailedToGetAzureSubscriptionsErrorMessage" xml:space="preserve">
<value>An error occurred while getting Azure subscriptions: {0}</value>
<comment></comment>
</data>
</data>
<data name="FailedToGetAzureResourceGroupsErrorMessage" xml:space="preserve">
<value>An error occurred while getting Azure resource groups: {0}</value>
<comment></comment>
</data>
</data>
<data name="FailedToGetAzureSqlServersErrorMessage" xml:space="preserve">
<value>An error occurred while getting Azure Sql Servers</value>
<comment></comment>
</data>
</data>
<data name="FailedToGetAzureSqlServersWithError" xml:space="preserve">
<value>An error occurred while getting Azure Sql Servers: '{0}'</value>
<comment></comment>
</data>
</data>
<data name="FirewallRuleCreationFailed" xml:space="preserve">
<value>An error occurred while creating a new firewall rule.</value>
<comment></comment>
</data>
</data>
<data name="FirewallRuleCreationFailedWithError" xml:space="preserve">
<value>An error occurred while creating a new firewall rule: '{0}'</value>
<comment></comment>
</data>
<data name="AzureSubscriptionFailedErrorMessage" xml:space="preserve">
<value>An error occurred while getting Azure subscriptions</value>
<comment></comment>
</data>
</data>
<data name="UnsupportedAuthType" xml:space="preserve">
<value>Unsupported account type '{0}' for this provider</value>
<comment></comment>
</data>
</root>
</data>
<data name="UserNotFoundError" xml:space="preserve">
<value>No user was found, cannot execute the operation</value>
<comment></comment>
</data>
<data name="UserNeedsAuthenticationError" xml:space="preserve">
<value>The current user must be reauthenticated before executing this operation </value>
<comment></comment>
</data>
</root>

View File

@@ -29,5 +29,6 @@ FailedToGetAzureSqlServersErrorMessage = An error occurred while getting Azure S
FailedToGetAzureSqlServersWithError = An error occurred while getting Azure Sql Servers: '{0}'
FirewallRuleCreationFailed = An error occurred while creating a new firewall rule.
FirewallRuleCreationFailedWithError = An error occurred while creating a new firewall rule: '{0}'
AzureSubscriptionFailedErrorMessage = An error occurred while getting Azure subscriptions
UnsupportedAuthType = Unsupported account type '{0}' for this provider
UnsupportedAuthType = Unsupported account type '{0}' for this provider
UserNotFoundError = No user was found, cannot execute the operation
UserNeedsAuthenticationError = The current user must be reauthenticated before executing this operation

View File

@@ -22,11 +22,6 @@
<target state="new">An error occurred while creating a new firewall rule.</target>
<note></note>
</trans-unit>
<trans-unit id="AzureSubscriptionFailedErrorMessage">
<source>An error occurred while getting Azure subscriptions</source>
<target state="new">An error occurred while getting Azure subscriptions</target>
<note></note>
</trans-unit>
<trans-unit id="UnsupportedAuthType">
<source>Unsupported account type '{0}' for this provider</source>
<target state="new">Unsupported account type '{0}' for this provider</target>
@@ -47,6 +42,16 @@
<target state="new">An error occurred while getting Azure subscriptions: {0}</target>
<note></note>
</trans-unit>
<trans-unit id="UserNeedsAuthenticationError">
<source>The current user must be reauthenticated before executing this operation </source>
<target state="new">The current user must be reauthenticated before executing this operation </target>
<note></note>
</trans-unit>
<trans-unit id="UserNotFoundError">
<source>No user was found, cannot execute the operation</source>
<target state="new">No user was found, cannot execute the operation</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>