Skip to content

RoNodeMethods should have conditional noexcept #389

@yrHeTaTeJlb

Description

@yrHeTaTeJlb

Throwing error callback

c4::yml::set_callbacks({ nullptr, nullptr, nullptr, [](const char*, std::size_t, c4::yml::Location, void*){ throw 42; } });

may lead to abort() in that case

ryml::ConstNodeRef node = Tree.rootref();
c4::csubstr invalidName = /*...*/;
node[invalidName];

bacuse noexcept operator[] calls this callback

    C4_ALWAYS_INLINE C4_PURE ConstImpl operator[] (csubstr k) const noexcept
    {
        _C4RV();
        size_t ch = tree_->find_child(id_, k);
        _RYML_CB_ASSERT(tree_->m_callbacks, ch != NONE);
        return {tree_, ch};
    }

I saw you mentioned that I can't return from error callback, so basically I can either call abort() or throw an exception, which in turn also leads to abort(). Config parsing error is an expected scenario in my case. So I'd like to handle such errors(even in debug build), rather than crashing the whole app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions