mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Handles a null reference exception (#2079)
This commit is contained in:
@@ -42,10 +42,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static ValidForFlag GetValidForFlag(SqlServerType serverType, Database database = null)
|
public static ValidForFlag GetValidForFlag(SqlServerType serverType, Database database = null)
|
||||||
{
|
{
|
||||||
var isSqlDw = false;
|
bool isSqlDw = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
isSqlDw = database.IsSqlDw;
|
// Database could be null here, handle NRE first.
|
||||||
|
if (database != null)
|
||||||
|
{
|
||||||
|
isSqlDw = database.IsSqlDw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -54,7 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
|||||||
Logger.Information($"This exception is expected when we are trying to access a readonly database. Exception: {e.Message}");
|
Logger.Information($"This exception is expected when we are trying to access a readonly database. Exception: {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetValidForFlag(serverType, database != null && isSqlDw);
|
return GetValidForFlag(serverType, isSqlDw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user