mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-11 10:38:32 -05:00
Added check if metadata is empty to throw error exception. (#1236)
* Added check if metadata is empty to throw error exception. * Changed error message. * Changed error message to be displayed when invalid Workspace ID is provided for AzureMonitorLogs.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -52,6 +53,17 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource.Monitor
|
||||
};
|
||||
|
||||
_metadata = JsonSerializer.Deserialize<WorkspaceResponse>(results, options);
|
||||
|
||||
if (_metadata?.Tables is null && _metadata?.Workspaces is null && _metadata?.TableGroups is null)
|
||||
{
|
||||
var errorMessage = JsonSerializer.Deserialize<ErrorResponse>(results, options);
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine(
|
||||
"The Log Analytics Workspace can not be reached. Please validate the Workspace ID, the correct tenant is selected, and that you have access to the workspace. ");
|
||||
builder.AppendLine($"Error Message: {errorMessage?.Error?.Message}");
|
||||
throw new Exception(builder.ToString());
|
||||
}
|
||||
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user