Improving profiler error messages (#658)

* Improving error messages

* Fixing stopping error message

* Cleaning up repeat error messages

* Changing error names
This commit is contained in:
Madeline MacDonald
2018-07-16 18:22:12 -07:00
committed by GitHub
parent b8c31e1138
commit ec9d51ede1
5 changed files with 69 additions and 3 deletions

View File

@@ -3669,6 +3669,14 @@ namespace Microsoft.SqlTools.ServiceLayer
} }
} }
public static string SessionNotFound
{
get
{
return Keys.GetString(Keys.SessionNotFound);
}
}
public static string UserCancelledSelectStep public static string UserCancelledSelectStep
{ {
get get
@@ -4551,6 +4559,16 @@ namespace Microsoft.SqlTools.ServiceLayer
return Keys.GetString(Keys.EditDataIncorrectTable, tableName); return Keys.GetString(Keys.EditDataIncorrectTable, tableName);
} }
public static string StopSessionFailed(String error)
{
return Keys.GetString(Keys.StopSessionFailed, error);
}
public static string StartSessionFailed(String error)
{
return Keys.GetString(Keys.StartSessionFailed, error);
}
public static string EnableAlertsTitle(String serverName) public static string EnableAlertsTitle(String serverName)
{ {
return Keys.GetString(Keys.EnableAlertsTitle, serverName); return Keys.GetString(Keys.EnableAlertsTitle, serverName);
@@ -6158,6 +6176,15 @@ namespace Microsoft.SqlTools.ServiceLayer
public const string AzureSystemDbProfilingError = "AzureSystemDbProfilingError"; public const string AzureSystemDbProfilingError = "AzureSystemDbProfilingError";
public const string StopSessionFailed = "StopSessionFailed";
public const string StartSessionFailed = "StartSessionFailed";
public const string SessionNotFound = "SessionNotFound";
public const string EnableAlertsTitle = "EnableAlertsTitle"; public const string EnableAlertsTitle = "EnableAlertsTitle";

View File

@@ -2027,6 +2027,20 @@
<value>Cannot profile Azure system databases</value> <value>Cannot profile Azure system databases</value>
<comment></comment> <comment></comment>
</data> </data>
<data name="StopSessionFailed" xml:space="preserve">
<value>Failed to stop session: {0}</value>
<comment>.
Parameters: 0 - error (String) </comment>
</data>
<data name="StartSessionFailed" xml:space="preserve">
<value>Failed to start session: {0}</value>
<comment>.
Parameters: 0 - error (String) </comment>
</data>
<data name="SessionNotFound" xml:space="preserve">
<value>Cannot find requested XEvent session</value>
<comment></comment>
</data>
<data name="EnableAlertsTitle" xml:space="preserve"> <data name="EnableAlertsTitle" xml:space="preserve">
<value>Enable Alerts - {0}</value> <value>Enable Alerts - {0}</value>
<comment>. <comment>.

View File

@@ -888,6 +888,9 @@ InvalidPathError = Cannot access the specified path on the server: {0}
# Profiler # Profiler
ProfilerConnectionNotFound = Connection not found ProfilerConnectionNotFound = Connection not found
AzureSystemDbProfilingError = Cannot profile Azure system databases AzureSystemDbProfilingError = Cannot profile Azure system databases
StopSessionFailed(String error) = Failed to stop session: {0}
StartSessionFailed(String error) = Failed to start session: {0}
SessionNotFound = Cannot find requested XEvent session
############################################################################# #############################################################################
# SQL Agent # SQL Agent

View File

@@ -3095,6 +3095,23 @@
<note>. <note>.
Parameters: 0 - unit (string) </note> Parameters: 0 - unit (string) </note>
</trans-unit> </trans-unit>
<trans-unit id="SessionNotFound">
<source>Cannot find requested XEvent session</source>
<target state="new">Cannot find requested XEvent session</target>
<note></note>
</trans-unit>
<trans-unit id="StopSessionFailed">
<source>Failed to stop session: {0}</source>
<target state="new">Failed to stop session: {0}</target>
<note>.
Parameters: 0 - error (String) </note>
</trans-unit>
<trans-unit id="StartSessionFailed">
<source>Failed to start session: {0}</source>
<target state="new">Failed to start session: {0}</target>
<note>.
Parameters: 0 - error (String) </note>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@@ -146,7 +146,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
} }
catch (Exception e) catch (Exception e)
{ {
await requestContext.SendError(e); await requestContext.SendError(new Exception(SR.StartSessionFailed(e.Message)));
} }
} }
@@ -159,13 +159,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
{ {
ProfilerSession session; ProfilerSession session;
monitor.StopMonitoringSession(parameters.OwnerUri, out session); monitor.StopMonitoringSession(parameters.OwnerUri, out session);
session.XEventSession.Stop();
if (session == null)
{
throw new Exception(SR.SessionNotFound);
}
session.XEventSession.Stop();
await requestContext.SendResult(new StopProfilingResult{}); await requestContext.SendResult(new StopProfilingResult{});
} }
catch (Exception e) catch (Exception e)
{ {
await requestContext.SendError(e); await requestContext.SendError(new Exception(SR.StopSessionFailed(e.Message)));
} }
} }