Namensräume
Varianten
Aktionen

std::current_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)
 
definiert in Header <exception>
std::exception_ptr current_exception()
(seit C++11)
Wenn während der Ausnahmebehandlung (in der Regel in einem catch Klausel) genannt wird, erfasst die aktuelle Ausnahme Objekt und erstellt eine std::exception_ptr, die einen Verweis hält an dieser Ausnahme-Objekt oder auf eine Kopie dieser Ausnahme-Objekt (es ist die Implementierung definiert, wenn eine Kopie ist hergestellt)
Original:
If called during exception handling (typically, in a catch clause), captures the current exception object and creates an std::exception_ptr that holds a reference to that exception object, or to a copy of that exception object (it is implementation-defined if a copy is made)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn die Implementierung dieser Funktion erfordert einen Aufruf new und der Aufruf fehlschlägt, wird der zurückgegebene Zeiger einen Verweis auf eine Instanz std::bad_alloc
Original:
If the implementation of this function requires a call to new and the call fails, the returned pointer will hold a reference to an instance of std::bad_alloc
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn die Implementierung dieser Funktion benötigt, um das aufgenommene Ausnahme-Objekt kopieren und die Kopie Konstruktor eine Ausnahme auslöst, wird die zurückgegebene Zeiger einen Verweis auf die Ausnahme ausgelöst. Wenn die Kopie Konstruktor des geworfenen Exception-Objekt wirft auch, kann die zurückgegebene Zeiger einen Verweis auf eine Instanz std::bad_exception um die Endlosschleife zu brechen .
Original:
If the implementation of this function requires to copy the captured exception object and its copy constructor throws an exception, the returned pointer will hold a reference to the exception thrown. If the copy constructor of the thrown exception object also throws, the returned pointer may hold a reference to an instance of std::bad_exception to break the endless loop.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn die Funktion aufgerufen wird, wenn keine Ausnahme gehandhabt wird, wird ein leerer std::exception_ptr zurückgegeben .
Original:
If the function is called when no exception is being handled, an empty std::exception_ptr is returned.
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

Eine Instanz std::exception_ptr hält einen Verweis auf die Ausnahme-Objekt oder eine Kopie des Exception-Objekt oder auf eine Instanz std::bad_alloc oder zu einer Instanz von std::bad_exception .
Original:
An instance of std::exception_ptr holding a reference to the exception object, or a copy of the exception object, or to an instance of std::bad_alloc or to an instance of std::bad_exception.
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

[edit]
#include <iostream>
#include <string>
#include <exception>
#include <stdexcept>
 
void handle_eptr(std::exception_ptr eptr) // passing by value is ok
{
    try {
        if (eptr != std::exception_ptr()) {
            std::rethrow_exception(eptr);
        }
    } catch(const std::exception& e) {
        std::cout << "Caught exception \"" << e.what() << "\"\n";
    }
}
 
int main()
{
    std::exception_ptr eptr;
    try {
        std::string().at(1); // this generates an std::out_of_range
    } catch(...) {
        eptr = std::current_exception(); // capture
    }
    handle_eptr(eptr);
} // destructor for std::out_of_range called here, when the eptr is destructed

Output:

Caught exception "basic_string::at"

[Bearbeiten] Siehe auch

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]
wirft die Ausnahme von einem std::exception_ptr
Original:
throws the exception from an std::exception_ptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktion) [edit]
schafft eine std::exception_ptr von einer Ausnahme-Objekt
Original:
creates an std::exception_ptr from an exception object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktions-Template) [edit]