Skip to content
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

Documentation for exception thrown within when expression #1086

Open
romglusker opened this issue Apr 18, 2024 · 5 comments
Open

Documentation for exception thrown within when expression #1086

romglusker opened this issue Apr 18, 2024 · 5 comments
Labels
type: bug The Standard does not describe the language as intended or implemented
Milestone

Comments

@romglusker
Copy link

Type of issue

Missing information

Description

I could not find good documentation on the expected behavior if an exception is thrown within the when expression. I wanted to confirm whether any additional exception handling was necessary in this use case.

Based on a quick test, it appears that the exception is suppressed, and the associated exception handler does not execute. Can the behavior be documented?

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/when

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/keywords/when.md

Document Version Independent Id

15502bbc-5355-2add-0fa8-ae31dc01c122

Article author

@BillWagner

Metadata

  • ID: 6ef10b29-fbf8-5af9-8f8b-a694a1416e33
  • Service: dotnet-csharp
  • Sub-service: lang-reference
@adamsitnik
Copy link
Member

@janvorli who would be the best person to improve the docs for exception handling?

@BillWagner
Copy link
Member

Adding @jcouv and @333fred

/cc @jskeet

I looked through the latest standard:

Neither specify behavior when evaluating an exception_filter throws an exception.

One requirement can be teased out: The language in the standard says that the catch clauses matches "when the exception_filter evalutes to true". Throwing an exception should mean the catch clause isn't execute.

The standard does have rules for the behavior when an exception is propagated from a catch clause, so the behavior when an exception filter thows an exception should be part of the standard.

If you both agree, I'll move this to the csharpstandard repo.

@jskeet
Copy link
Contributor

jskeet commented Apr 19, 2024

Yes, we should definitely document this.

@BillWagner BillWagner transferred this issue from dotnet/docs Apr 25, 2024
@BillWagner BillWagner added the type: bug The Standard does not describe the language as intended or implemented label Apr 25, 2024
@BillWagner
Copy link
Member

@jskeet I propose adding this to the C# 8 milestone.

@jskeet
Copy link
Contributor

jskeet commented Apr 25, 2024

Yup, works for me.

@jskeet jskeet added this to the C# 8.0 milestone Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug The Standard does not describe the language as intended or implemented
Projects
None yet
Development

No branches or pull requests

4 participants