Skip to content

Commit fc73369

Browse files
TylerMSFTTylerMSFT
authored andcommitted
fix section about types of exception handling
1 parent a4698e8 commit fc73369

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

docs/cpp/transporting-exceptions-between-threads.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
22
description: "Learn more about: Transporting exceptions between threads"
33
title: "Transporting exceptions between threads"
4-
ms.date: "05/07/2019"
4+
ms.date: 05/02/2023
55
helpviewer_keywords: ["std::current_exception", "transporting exceptions between threads", "std::copy_exception", "exception_ptr", "std::exception_ptr", "std::rethrow_exception", "current_exception", "transport exceptions between threads", "copy_exception", "rethrow_exception", "move exceptions between threads"]
6-
ms.assetid: 5c95d57b-acf5-491f-8122-57c5df0edd98
76
---
87
# Transporting exceptions between threads
98

@@ -24,23 +23,23 @@ namespace std
2423

2524
### Parameters
2625

27-
*unspecified*\
26+
*`unspecified`*\
2827
An unspecified internal class that is used to implement the `exception_ptr` type.
2928

30-
*p*\
29+
*`p`*\
3130
An `exception_ptr` object that references an exception.
3231

33-
*E*\
32+
*`E`*\
3433
A class that represents an exception.
3534

36-
*e*\
35+
*`e`*\
3736
An instance of the parameter `E` class.
3837

3938
## Return value
4039

4140
The `current_exception` function returns an `exception_ptr` object that references the exception that is currently in progress. If no exception is in progress, the function returns an `exception_ptr` object that is not associated with any exception.
4241

43-
The `make_exception_ptr` function returns an `exception_ptr` object that references the exception specified by the *e* parameter.
42+
The `make_exception_ptr` function returns an `exception_ptr` object that references the exception specified by the *`e`* parameter.
4443

4544
## Remarks
4645

@@ -66,26 +65,26 @@ For more information about the C++ Standards committee proposal, search the Inte
6665

6766
### Exception-handling models and compiler options
6867

69-
Your application's exception-handling model determines whether it can catch and transport an exception. Visual C++ supports three models that can handle C++ exceptions, structured exception handling (SEH) exceptions, and common language runtime (CLR) exceptions. Use the [/EH](../build/reference/eh-exception-handling-model.md) and [/clr](../build/reference/clr-common-language-runtime-compilation.md) compiler options to specify your application's exception-handling model.
68+
Your application's exception-handling model determines whether it can catch and transport an exception. Visual C++ supports three models for handling C++ exceptions: [ISO-standard C++ exception handling](/cpp/cpp/errors-and-exception-handling-modern-cpp?view=msvc-170), [structured exception handling (SEH)](/windows/win32/debug/structured-exception-handling), and [common language runtime (CLR) exceptions](/cpp/extensions/exception-handling-cpp-component-extensions). Use the [`/EH`](../build/reference/eh-exception-handling-model.md) and [`/clr`](../build/reference/clr-common-language-runtime-compilation.md) compiler options to specify your application's exception-handling model.
7069

7170
Only the following combination of compiler options and programming statements can transport an exception. Other combinations either cannot catch exceptions, or can catch but cannot transport exceptions.
7271

73-
- The **/EHa** compiler option and the **`catch`** statement can transport SEH and C++ exceptions.
72+
- The **`/EHa`** compiler option and the **`catch`** statement can transport SEH and C++ exceptions.
7473

75-
- The **/EHa**, **/EHs**, and **/EHsc** compiler options and the **`catch`** statement can transport C++ exceptions.
74+
- The **`/EHa`**, **`/EHs`**, and **`/EHsc`** compiler options and the **`catch`** statement can transport C++ exceptions.
7675

77-
- The **/CLR** compiler option and the **`catch`** statement can transport C++ exceptions. The **/CLR** compiler option implies specification of the **/EHa** option. Note that the compiler does not support transporting managed exceptions. This is because managed exceptions, which are derived from the [System.Exception class](../standard-library/exception-class.md), are already objects that you can move between threads by using the facilities of the common languange runtime.
76+
- The **`/CLR`** compiler option and the **`catch`** statement can transport C++ exceptions. The **`/clr`** compiler option implies specification of the **`/EHa`** option. Note that the compiler does not support transporting managed exceptions. This is because managed exceptions, which are derived from the [System.Exception class](../standard-library/exception-class.md), are already objects that you can move between threads by using the facilities of the common language runtime.
7877

7978
> [!IMPORTANT]
80-
> We recommend that you specify the **/EHsc** compiler option and catch only C++ exceptions. You expose yourself to a security threat if you use the **/EHa** or **/CLR** compiler option and a **`catch`** statement with an ellipsis *exception-declaration* (`catch(...)`). You probably intend to use the **`catch`** statement to capture a few specific exceptions. However, the `catch(...)` statement captures all C++ and SEH exceptions, including unexpected ones that should be fatal. If you ignore or mishandle an unexpected exception, malicious code can use that opportunity to undermine the security of your program.
79+
> We recommend that you specify the **`/EHsc`** compiler option and catch only C++ exceptions. You expose yourself to a security threat if you use the **`/EHa`** or **`/clr`** compiler option and a **`catch`** statement with an ellipsis *exception-declaration* (`catch(...)`). You probably intend to use the **`catch`** statement to capture a few specific exceptions. However, the `catch(...)` statement captures all C++ and SEH exceptions, including unexpected ones that should be fatal. If you ignore or mishandle an unexpected exception, malicious code can use that opportunity to undermine the security of your program.
8180
8281
## Usage
8382

8483
The following sections describe how to transport exceptions by using the `exception_ptr` type, and the `current_exception`, `rethrow_exception`, and `make_exception_ptr` functions.
8584

8685
## exception_ptr type
8786

88-
Use an `exception_ptr` object to reference the current exception or an instance of a user-specified exception. In the Microsoft implementation, an exception is represented by an [EXCEPTION_RECORD](/windows/win32/api/winnt/ns-winnt-exception_record) structure. Each `exception_ptr` object includes an exception reference field that points to a copy of the `EXCEPTION_RECORD` structure that represents the exception.
87+
Use an `exception_ptr` object to reference the current exception or an instance of a user-specified exception. In the Microsoft implementation, an exception is represented by an [`EXCEPTION_RECORD`](/windows/win32/api/winnt/ns-winnt-exception_record) structure. Each `exception_ptr` object includes an exception reference field that points to a copy of the `EXCEPTION_RECORD` structure that represents the exception.
8988

9089
When you declare an `exception_ptr` variable, the variable is not associated with any exception. That is, its exception reference field is NULL. Such an `exception_ptr` object is called a *null exception_ptr*.
9190

@@ -111,7 +110,7 @@ Successive calls to the `current_exception` function return `exception_ptr` obje
111110

112111
### SEH exceptions
113112

114-
If you use the **/EHa** compiler option, you can catch an SEH exception in a C++ **`catch`** block. The `current_exception` function returns an `exception_ptr` object that references the SEH exception. And the `rethrow_exception` function throws the SEH exception if you call it with thetransported `exception_ptr` object as its argument.
113+
If you use the **`/EHa`** compiler option, you can catch an SEH exception in a C++ **`catch`** block. The `current_exception` function returns an `exception_ptr` object that references the SEH exception. And the `rethrow_exception` function throws the SEH exception if you call it with thetransported `exception_ptr` object as its argument.
115114

116115
The `current_exception` function returns a null `exception_ptr` if you call it in an SEH **`__finally`** termination handler, an **`__except`** exception handler, or the **`__except`** filter expression.
117116

@@ -241,10 +240,10 @@ exception_ptr 1: Caught a myException exception.
241240

242241
## Requirements
243242

244-
**Header:** \<exception>
243+
**Header:** `<exception>`
245244

246245
## See also
247246

248-
[Exception Handling](../cpp/exception-handling-in-visual-cpp.md)<br/>
249-
[/EH (Exception Handling Model)](../build/reference/eh-exception-handling-model.md)<br/>
250-
[/clr (Common Language Runtime Compilation)](../build/reference/clr-common-language-runtime-compilation.md)
247+
[Exception Handling](../cpp/exception-handling-in-visual-cpp.md)
248+
[`/EH` (Exception Handling Model)](../build/reference/eh-exception-handling-model.md)\
249+
[`/clr` (Common Language Runtime Compilation)](../build/reference/clr-common-language-runtime-compilation.md)

0 commit comments

Comments
 (0)