diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index e7534d9c..e6f70b17 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -60,7 +60,7 @@ struct type_version { template constexpr const char *getTypeName(T *t) noexcept { TypeInfoCatcher tnc; - model(&tnc, t); + oxIgnoreError(model(&tnc, t)); return tnc.name; } diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp index ac1546e8..b0f57e6e 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp @@ -235,7 +235,7 @@ Error FileStoreTemplate::decLinks(InodeId_t id) { if (item.valid()) { item->links--; if (item->links == 0) { - remove(item); + oxReturnError(remove(item)); } return OxError(0); } diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index 7cd3e39d..705e4c5b 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -155,7 +155,7 @@ ox::Error Directory::mkdir(PathIterator path, bool parents // determine if already exists auto name = nameBuff; - path.get(name); + oxReturnError(path.get(name)); auto childInode = find(name->c_str()); if (!childInode.ok()) { // if this is not the last item in the path and parents is disabled, @@ -223,7 +223,7 @@ ox::Error Directory::write(PathIterator path, InodeId_t in // insert the new entry on this directory // get the name - path.next(name); + oxReturnError(path.next(name)); // find existing version of directory oxTrace("ox::fs::Directory::write") << "Searching for directory inode" << m_inodeId; diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index 72c1e761..1a527cc8 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -302,7 +302,7 @@ std::map tests = { oxAssert(ox::writeMC(dataBuff, dataBuffLen, &testIn), "Data generation failed"); auto type = ox::buildTypeDef(&testIn); oxAssert(type.error, "Descriptor write failed"); - ox::walkModel(type.value, dataBuff, dataBuffLen, + oxReturnError(ox::walkModel(type.value, dataBuff, dataBuffLen, [](const ox::Vector&, const ox::Vector&, const ox::DescriptorField &f, ox::MetalClawReader *rdr) -> ox::Error { //std::cout << f.fieldName.c_str() << '\n'; auto fieldName = f.fieldName.c_str(); @@ -387,7 +387,7 @@ std::map tests = { } return OxError(0); } - ); + )); delete type.value; return OxError(0); } diff --git a/deps/ox/src/ox/oc/test/tests.cpp b/deps/ox/src/ox/oc/test/tests.cpp index ceeacb5a..0e3c8406 100644 --- a/deps/ox/src/ox/oc/test/tests.cpp +++ b/deps/ox/src/ox/oc/test/tests.cpp @@ -182,7 +182,7 @@ std::map tests = { oxAssert(ocErr, "Data generation failed"); auto type = ox::buildTypeDef(&testIn); oxAssert(type.error, "Descriptor write failed"); - ox::walkModel(type.value, ox::bit_cast(oc.data()), oc.size(), + oxReturnError(ox::walkModel(type.value, ox::bit_cast(oc.data()), oc.size(), [](const ox::Vector&, const ox::Vector&, const ox::DescriptorField &f, ox::OrganicClawReader *rdr) -> ox::Error { //std::cout << f.fieldName.c_str() << '\n'; auto fieldName = f.fieldName.c_str(); @@ -267,7 +267,7 @@ std::map tests = { } return OxError(0); } - ); + )); delete type.value; return OxError(0); diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 36a23daf..553b2b5e 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -17,40 +17,45 @@ namespace ox { -struct BaseError { +struct [[nodiscard]] Error { const char *msg = nullptr; const char *file = ""; uint16_t line = 0; + uint64_t m_i = 0; - BaseError() = default; + constexpr Error(uint64_t i = 0) { + m_i = i; + } - constexpr BaseError(const BaseError &o) noexcept { + constexpr Error(const Error &o) noexcept { msg = o.msg; file = o.file; line = o.line; } - constexpr BaseError operator=(const BaseError &o) noexcept { + constexpr Error &operator=(const Error &o) noexcept { msg = o.msg; file = o.file; line = o.line; return *this; } + constexpr operator uint64_t() const noexcept { + return m_i; + } + }; -using Error = Integer; - static constexpr Error _error(const char *file, uint32_t line, uint64_t errCode, const char *msg = nullptr) { - Error err = static_cast(errCode); - err.file = file; - err.line = line; - err.msg = msg; + auto err = static_cast(errCode); + err.file = file; + err.line = line; + err.msg = msg; return err; } template -struct ValErr { +struct [[nodiscard]] ValErr { T value; Error error; diff --git a/deps/ox/src/ox/std/strongint.hpp b/deps/ox/src/ox/std/strongint.hpp index 72a6b722..5e71a443 100644 --- a/deps/ox/src/ox/std/strongint.hpp +++ b/deps/ox/src/ox/std/strongint.hpp @@ -126,7 +126,9 @@ constexpr Integer::Integer(const Integer &i) noexcept: Base(i) template constexpr Integer Integer::operator=(Integer i) noexcept { - Base::operator=(i); + // needed in case T has nodiscard + constexpr auto ignore = [](Base) {}; + ignore(Base::operator=(i)); m_i = i.m_i; return *this; } diff --git a/deps/ox/src/ox/std/trace.hpp b/deps/ox/src/ox/std/trace.hpp index 174b97ac..a62977b9 100644 --- a/deps/ox/src/ox/std/trace.hpp +++ b/deps/ox/src/ox/std/trace.hpp @@ -51,6 +51,12 @@ class OutStream { return *this; } + inline OutStream &operator<<(Error err) { + m_msg.msg += m_delimiter; + m_msg.msg += static_cast(err); + return *this; + } + /** * del sets the delimiter between log segments. */