diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs
index 6cdd62aa..bc685eff 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs
@@ -162,8 +162,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
connectionInfo.SqlConnection = connectionInfo.Factory.CreateSqlConnection(connectionString);
connectionInfo.SqlConnection.Open();
}
- catch(Exception ex)
+ catch (SqlException ex)
{
+ response.ErrorNumber = ex.Number;
+ response.ErrorMessage = ex.Message;
+ response.Messages = ex.ToString();
+ return response;
+ }
+ catch (Exception ex)
+ {
+ response.ErrorMessage = ex.Message;
response.Messages = ex.ToString();
return response;
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectResponse.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectResponse.cs
index 9066efa8..9dcf061e 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectResponse.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectResponse.cs
@@ -16,10 +16,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
public string ConnectionId { get; set; }
///
- /// Gets or sets any connection error messages
+ /// Gets or sets any detailed connection error messages.
///
public string Messages { get; set; }
+ ///
+ /// Error message returned from the engine for a connection failure reason, if any.
+ ///
+ public string ErrorMessage { get; set; }
+
+ ///
+ /// Error number returned from the engine for connection failure reason, if any.
+ ///
+ public int ErrorNumber { get; set; }
+
///
/// Information about the connected server.
///