-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated exception messages #1298
Conversation
Ideally have full context on all surfaces unless its an issue. |
Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosException.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Debug.Assert instead for internal members?
Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosException.cs
Outdated
Show resolved
Hide resolved
@@ -68,6 +69,9 @@ public class CosmosException : Exception | |||
this.DiagnosticsContext = new CosmosDiagnosticsContextCore(); | |||
} | |||
|
|||
/// <inheritdoc/> | |||
public override string Message => this.ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove - ToString() contain information like the call stack that is intentionally not included in the Exception.Message. Changing this violates basic Exception contract - same message as ToString without callstack or diagnostics might be fine or the base class implementation just using the message explicitly passed in. I think we discussed this in the past - and due to the fact that the ctor of CosmosException is internal - so the exception cannot ever be created by customers this is kind of a gray area - you could argue that we are the only entity deciding which information is critical. But if there is no hard reason requiring us to include stacktrace and diagnostics I wouldn't include them in Message to avoid exposing PII or data considered sensitive by customers in an Exception.Message - where they usually aren't included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind - I remember teh discussion and think the stackTrace and diagnostics would be null in the exceptions actually thornw to the customer - and were just used to pass through context through the request pipeline. If so ignore the comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it so the Message only contains the StatusCode, SubStatusCode, ActivityId, and original message from the service. Only the ToString() will contain the full stack trace and diagnostics.
Pull Request Template
Description
Updating the exception messages to provide a consistent story with all the information. This ensures that if a user only collects a Message or other property there will always be the information required to troubleshoot it.
ResponseMessage
CosmosException:
Example output CosmosException.Message and ResponseMessage.ErrorMessage
Example output CosmosException.ToString()