error code vs error condition

From http://en.cppreference.com/w/cpp/error/error_condition

std::error_condition is a platform-independent error code. Like
std::error_code, it is uniquely identified by an integer value and a
std::error_category, but unlike std::error_code, the value is not
platform-dependent.

So, the advantage is your error code isn’t specific to the platform you’re working on when using std::error_condition.

With an std::error_code

Each std::error_code object holds a pair of error code originating
from the operating system, or some low-level interface

So, the error_code will reference something specific to your platform, a piece of hardware etc etc.

It may be advantageous to use both. The error_condition is the “portable abstraction” so would be the generic error message to give to the user and the error_code would be the platform dependent information that would be useful for specific debug.

A typical implementation [of error_condition] holds one integer data member (the value) and
a pointer to an std::error_category.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)