thomaslevesque / CosmosDBStudio

A tool to browse and query Azure Cosmos DB databases
MIT License
54 stars 12 forks source link

Better error messages for queries #21

Open thomaslevesque opened 4 years ago

thomaslevesque commented 4 years ago

Errors returned by Cosmos DB are pure cr*p. Here's an exemple of the body of an error response (formatted):

{
        "code": "BadRequest",
        "message": "Gateway Failed to Retrieve Query Plan: Message: {\"errors\":[{\"severity\":\"Error\",\"location\":{\"start\":36,\"end\":36},\"code\":\"SC1002\",\"message\":\"Syntax error, unexpected end-of-file.\"}]}\r\nActivityId: 3d7a2504-ea2b-4075-a957-0ca8e4ae05f8, Microsoft.Azure.Documents.Common/2.11.0, Microsoft.Azure.Documents.Common/2.11.0"
}

The message content is plain text, with some JSON in the middle of it. It's unreadable, and the actual error data is difficult to extract.

It would be nice to parse this mess, display a clear error message, and show error squiggles in the editor at the specified location.

thomaslevesque commented 4 years ago

Related: https://github.com/Azure/azure-cosmos-dotnet-v3/issues/1910