Namensräume
Varianten
Aktionen

std::uncaught_exception

Aus cppreference.com
< cpp‎ | error

 
 
 
Fehlerbehandlung
Exception Handling
Original:
Exception handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
exception
uncaught_exception
exception_ptr(C++11)
make_exception_ptr(C++11)
current_exception(C++11)
rethrow_exception(C++11)
nested_exception(C++11)
throw_with_nested(C++11)
rethrow_if_nested(C++11)
Ausnahmebehandlung Ausfälle
Original:
Exception handling failures
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
terminate
terminate_handler
get_terminate(C++11)
set_terminate
unexpected(veraltet)
bad_exception
unexpected_handler(veraltet)
get_unexpected(C++11)(veraltet)
set_unexpected(veraltet)
Exception Kategorien
Original:
Exception categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
logic_error
invalid_argument
domain_error
length_error
out_of_range
runtime_error
range_error
overflow_error
underflow_error
Fehlercodes
Original:
Error codes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Fehlercodes
errno
Assertions
Original:
Assertions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
assert
system_error Anlage
Original:
system_error facility
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
error_category(C++11)
generic_category(C++11)
system_category(C++11)
error_condition(C++11)
errc(C++11)
error_code(C++11)
system_error(C++11)
 
Defined in header <exception>
bool uncaught_exception();
Erkennt, ob der aktuelle Thread hat eine Live-Exception-Objekt, das heißt, es wird eine Ausnahme geworfen wurde und noch nicht eingetragen eine passende catch-Klausel, std::terminate oder std::unexpected. Mit anderen Worten, wenn detektiert std::uncaught_exception Stapel Abwickeln Derzeit wird .
Original:
Detects if the current thread has a live exception object, that is, an exception has been thrown and not yet entered a matching catch clause, std::terminate or std::unexpected. In other words, std::uncaught_exception detects if stack unwinding is currently in progress.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Manchmal ist es sicher eine Ausnahme auch während std::uncaught_exception() == true werfen. Zum Beispiel, wenn Ausnahmen abgefangen werden und ignoriert in einem Destruktor, können sie sich nicht fortpflanzen aus ihm heraus und werden nicht an std::terminate führen .
Original:
Sometimes it's safe to throw an exception even while std::uncaught_exception() == true. For example, if exceptions are caught and ignored in a destructor, they can't propagate out of it and won't lead to std::terminate.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Parameter

(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Rückgabewert

true, wenn Stack Unwinding derzeit im Gange ist in diesem Thread .
Original:
true if stack unwinding is currently in progress in this thread.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Ausnahmen

noexcept specification:  
noexcept
  (seit C++11)

[Bearbeiten] Beispiel

#include <iostream>
#include <exception>
#include <stdexcept>
 
struct Foo {
    ~Foo() {
        if (std::uncaught_exception()) {
            std::cout << "~Foo() called during stack unwinding\n";
        } else {
            std::cout << "~Foo() called normally\n";
        }
    }
};
int main()
{
    Foo f;
    try {
        Foo f;
        std::cout << "Exception thrown\n";
        throw std::runtime_error("test exception");
    } catch (const std::exception& e) {
        std::cout << "Exception caught: " << e.what() << '\n';
    }
}

Output:

Exception thrown
~Foo() called during stack unwinding
Exception caught: test exception
~Foo() called normally

[Bearbeiten] Siehe auch

Funktion aufgerufen, wenn Ausnahmebehandlung ausfällt
Original:
function called when exception handling fails
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktion) [edit]
teilte Zeigertyp für den Umgang mit Exception-Objekte
Original:
shared pointer type for handling exception objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(typedef) [edit]

[Bearbeiten] Externer Links

GOTW issue 47: Uncaught Exceptions