Skip to content

Commit

Permalink
allow concatenating of Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Nov 16, 2024
1 parent e785995 commit 4ddf749
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libheif/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const char* cUnknownError = "Unknown error";

const Error Error::Ok(heif_error_Ok);

const Error Error::InternalError{heif_error_Unsupported_feature, // TODO: use better value
heif_suberror_Unspecified,
"Internal error"};


Error::Error() = default;

Expand Down
11 changes: 11 additions & 0 deletions libheif/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,23 @@ class Error

static const Error Ok;

static const Error InternalError;

static const char kSuccess[];

bool operator==(const Error& other) const { return error_code == other.error_code; }

bool operator!=(const Error& other) const { return !(*this == other); }

Error operator||(const Error& other) const {
if (error_code != heif_error_Ok) {
return *this;
}
else {
return other;
}
}

operator bool() const { return error_code != heif_error_Ok; }

static const char* get_error_string(heif_error_code err);
Expand Down

0 comments on commit 4ddf749

Please sign in to comment.