testcontainers-cpp 0.2.0
Native C++20 Testcontainers over the Docker Engine API
Loading...
Searching...
No Matches
testcontainers::DockerError Class Reference

Failure while talking to the Docker daemon (transport, HTTP, or API error). More...

#include <testcontainers/Error.hpp>

Inheritance diagram for testcontainers::DockerError:
testcontainers::Error testcontainers::NotFoundError testcontainers::TransportTimeoutError

Public Member Functions

 DockerError (const std::string &what)
 DockerError (const std::string &what, std::optional< int > status_code, std::string resource_id={})
std::optional< int > status_code () const noexcept
const std::string & resource_id () const noexcept

Detailed Description

Failure while talking to the Docker daemon (transport, HTTP, or API error).

status_code() carries the HTTP status when the daemon replied with an error response (std::nullopt for transport-level failures that never got one). resource_id() carries the id or name of the container / image / network / volume / exec instance the failed call was about — best-effort: it is "" when the call has no single subject (e.g. list_containers), may be empty on parse- and transport-level failures, and on two-resource calls (connect_network) names the primary one.

More status-specific subtypes may be introduced over time (e.g. for 409), so do not assume the dynamic type of a non-404 failure is exactly DockerError — dispatch on status_code() instead.

Constructor & Destructor Documentation

◆ DockerError() [1/2]

testcontainers::DockerError::DockerError ( const std::string & what)
inlineexplicit

◆ DockerError() [2/2]

testcontainers::DockerError::DockerError ( const std::string & what,
std::optional< int > status_code,
std::string resource_id = {} )
inline

Member Function Documentation

◆ status_code()

std::optional< int > testcontainers::DockerError::status_code ( ) const
inlinenoexcept

◆ resource_id()

const std::string & testcontainers::DockerError::resource_id ( ) const
inlinenoexcept