LLFIO v2.00
Loading...
Searching...
No Matches
llfio_v2_xxx::error_info Struct Reference

The cause of the failure of an operation in LLFIO. More...

#include "status_code.hpp"

Public Member Functions

 error_info ()=default
 Default constructor.
 
 error_info (std::error_code _ec)
 
 OUTCOME_TEMPLATE (class ErrorCondEnum) OUTCOME_TREQUIRES(OUTCOME_TPRED(std
 Implicit construct from an error condition enum.
 
int value () const noexcept
 Retrieve the value of the error code.
 
filesystem::path path1 () const
 
filesystem::path path2 () const
 
std::string message () const
 
void throw_exception () const
 

Friends

std::error_code make_error_code (error_info ei)
 

Detailed Description

The cause of the failure of an operation in LLFIO.

Constructor & Destructor Documentation

◆ error_info()

llfio_v2_xxx::error_info::error_info ( std::error_code  _ec)
inlineexplicit
656 : ec(_ec)
657{
658// Here is a VERY useful place to breakpoint!
659#ifndef LLFIO_DISABLE_PATHS_IN_FAILURE_INFO
660 if(ec)
661 {
662 detail::fill_failure_info(*this, this->ec);
663 }
664#endif
665}

Member Function Documentation

◆ message()

std::string llfio_v2_xxx::error_info::message ( ) const
inline

Retrieve a descriptive message for this failure, possibly with paths and stack backtraces. Extra detail only appears if called from the same thread as where the failure occurred.

547 {
548 std::string ret(ec.message());
549#if !LLFIO_DISABLE_PATHS_IN_FAILURE_INFO
550 detail::append_path_info(*this, ret);
551#endif
552 return ret;
553 }

◆ OUTCOME_TEMPLATE()

llfio_v2_xxx::error_info::OUTCOME_TEMPLATE ( class ErrorCondEnum  )
inline

Implicit construct from an error condition enum.

504 : error_info(make_error_code(std::forward<ErrorCondEnum>(v)))
505 {
506 }
error_info()=default
Default constructor.

◆ path1()

filesystem::path llfio_v2_xxx::error_info::path1 ( ) const
inline

Retrieve any first path associated with this failure. Note this only works if called from the same thread as where the failure occurred.

513 {
514#if !LLFIO_DISABLE_PATHS_IN_FAILURE_INFO
515 if(QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id() == _thread_id)
516 {
517 auto &tls = detail::tls_errored_results();
518 const char *path1 = tls.get(_tls_path_id1);
519 if(path1 != nullptr)
520 {
521 return filesystem::path(path1);
522 }
523 }
524#endif
525 return {};
526 }
filesystem::path path1() const
Definition status_code.hpp:512

◆ path2()

filesystem::path llfio_v2_xxx::error_info::path2 ( ) const
inline

Retrieve any second path associated with this failure. Note this only works if called from the same thread as where the failure occurred.

530 {
531#if !LLFIO_DISABLE_PATHS_IN_FAILURE_INFO
532 if(QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id() == _thread_id)
533 {
534 auto &tls = detail::tls_errored_results();
535 const char *path2 = tls.get(_tls_path_id2);
536 if(path2 != nullptr)
537 {
538 return filesystem::path(path2);
539 }
540 }
541#endif
542 return {};
543 }
filesystem::path path2() const
Definition status_code.hpp:529

◆ throw_exception()

void llfio_v2_xxx::error_info::throw_exception ( ) const
inline

Throw this failure as a C++ exception. Firstly if the error code matches any of the standard C++ exception types e.g. bad_alloc, we throw those types using the string from message() where possible. We then will throw an error exception type.

664{
665 std::string msg;
666 LLFIO_EXCEPTION_TRY
667 {
668 msg = message();
669 }
670 LLFIO_EXCEPTION_CATCH_ALL {}
671#ifdef __cpp_exceptions
672 OUTCOME_V2_NAMESPACE::try_throw_std_exception_from_error(ec, msg);
673#endif
674 LLFIO_EXCEPTION_THROW(error(*this));
675}
std::string message() const
Definition status_code.hpp:546

◆ value()

int llfio_v2_xxx::error_info::value ( ) const
inlinenoexcept

Retrieve the value of the error code.

509{ return ec.value(); }

Friends And Related Symbol Documentation

◆ make_error_code

std::error_code make_error_code ( error_info  ei)
friend
638{
639 return ei.ec;
640}

The documentation for this struct was generated from the following files: