diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index 165b8de3..86380e86 100755 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -3669,6 +3669,14 @@ namespace Microsoft.SqlTools.ServiceLayer } } + public static string SessionNotFound + { + get + { + return Keys.GetString(Keys.SessionNotFound); + } + } + public static string UserCancelledSelectStep { get @@ -4551,6 +4559,16 @@ namespace Microsoft.SqlTools.ServiceLayer 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) { return Keys.GetString(Keys.EnableAlertsTitle, serverName); @@ -6158,6 +6176,15 @@ namespace Microsoft.SqlTools.ServiceLayer 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"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index 903eb56f..67b36ecd 100755 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -2027,6 +2027,20 @@ Cannot profile Azure system databases + + Failed to stop session: {0} + . + Parameters: 0 - error (String) + + + Failed to start session: {0} + . + Parameters: 0 - error (String) + + + Cannot find requested XEvent session + + Enable Alerts - {0} . diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index 248de2dc..deb95e41 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -888,6 +888,9 @@ InvalidPathError = Cannot access the specified path on the server: {0} # Profiler ProfilerConnectionNotFound = Connection not found 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 diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index 566ba978..576b7b98 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -3095,6 +3095,23 @@ . Parameters: 0 - unit (string) + + Cannot find requested XEvent session + Cannot find requested XEvent session + + + + Failed to stop session: {0} + Failed to stop session: {0} + . + Parameters: 0 - error (String) + + + Failed to start session: {0} + Failed to start session: {0} + . + Parameters: 0 - error (String) + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/Profiler/ProfilerService.cs b/src/Microsoft.SqlTools.ServiceLayer/Profiler/ProfilerService.cs index 9f327f8b..33a92e3b 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Profiler/ProfilerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Profiler/ProfilerService.cs @@ -146,7 +146,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler } 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; 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{}); } catch (Exception e) { - await requestContext.SendError(e); + await requestContext.SendError(new Exception(SR.StopSessionFailed(e.Message))); } }