From 230244ca147e76cffb0db0647ebce87fd2fec366 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sun, 18 Feb 2024 09:56:31 +0100 Subject: [PATCH 1/3] Throw a regular runtime_error in EbmlBinary We don't need a special case of runtime_error, there is no error code. --- src/EbmlBinary.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EbmlBinary.cpp b/src/EbmlBinary.cpp index e1ab8edc..96fae854 100644 --- a/src/EbmlBinary.cpp +++ b/src/EbmlBinary.cpp @@ -7,9 +7,9 @@ \author Julien Coloos */ #include +#include #include "ebml/EbmlBinary.h" -#include "ebml/StdIOCallback.h" namespace libebml { @@ -85,7 +85,7 @@ filepos_t EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully) Data = (GetSize() < std::numeric_limits::max()) ? static_cast(malloc(GetSize())) : nullptr; if (Data == nullptr) - throw CRTError(std::string("Error allocating data")); + throw std::runtime_error("Error allocating data"); SetValueIsSet(); return input.read(Data, GetSize()); } From 6df09faa0ec64151feef7593fcb427954227341e Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sun, 18 Feb 2024 10:26:56 +0100 Subject: [PATCH 2/3] throw ios_base::failure in StdIOCallback This seems more appropriate. --- src/StdIOCallback.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/StdIOCallback.cpp b/src/StdIOCallback.cpp index 2eb15448..5a67b94a 100644 --- a/src/StdIOCallback.cpp +++ b/src/StdIOCallback.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "ebml/StdIOCallback.h" @@ -56,7 +57,7 @@ StdIOCallback::StdIOCallback(const char*Path, const open_mode aMode) if(File==nullptr) { stringstream Msg; Msg<<"Can't open stdio file \""< Date: Sun, 18 Feb 2024 09:34:51 +0100 Subject: [PATCH 3/3] move CRTError in its own header So the user doesn't have to include StdIOCallback.h remove custom CRTError --- ebml/StdIOCallback.h | 17 ----------------- src/StdIOCallback.cpp | 13 ------------- 2 files changed, 30 deletions(-) diff --git a/ebml/StdIOCallback.h b/ebml/StdIOCallback.h index 808071db..870a5a69 100644 --- a/ebml/StdIOCallback.h +++ b/ebml/StdIOCallback.h @@ -9,9 +9,6 @@ #include "IOCallback.h" -#include -#include - namespace libebml { enum open_mode { @@ -21,20 +18,6 @@ enum open_mode { MODE_SAFE }; -class EBML_DLL_API CRTError:public std::runtime_error -{ -// Variablen... -private: - int Error; - -// Methoden... -public: - CRTError(int Error,const std::string&Description); - explicit CRTError(const std::string&Description,int Error=errno); - - int getError() const noexcept { return Error; } -}; - // This class is currently private to the library, so there's no MATROSKA_EXPORT. class EBML_DLL_API StdIOCallback:public IOCallback { diff --git a/src/StdIOCallback.cpp b/src/StdIOCallback.cpp index 5a67b94a..39cd4b1e 100644 --- a/src/StdIOCallback.cpp +++ b/src/StdIOCallback.cpp @@ -18,19 +18,6 @@ using namespace std; namespace libebml { -CRTError::CRTError(int nError, const std::string & Description) - :std::runtime_error(Description+": "+strerror(nError)) - ,Error(nError) -{ -} - -CRTError::CRTError(const std::string & Description,int nError) - :std::runtime_error(Description+": "+strerror(nError)) - ,Error(nError) -{ -} - - StdIOCallback::StdIOCallback(const char*Path, const open_mode aMode) { assert(Path!=nullptr);