Skip to content

AException#

Abstract AUI exception.

Header:#include <AUI/Common/AException.h>
CMake:aui_link(my_target PUBLIC aui::core)

Detailed Description#

Unlike std::exception, AException is capable to capture stack traces and efficiently output them to std::ostream. Also exception nesting is possible (via causedBy()).

Examples#

examples/7guis/cells/src/Spreadsheet.h

7GUIs Cells - Spreadsheet processor (Excel).

    Cell& operator[](glm::uvec2 pos) { return *mCells[pos.y * mSize.x + pos.x]; }

    const Cell& operator[](glm::uvec2 pos) const {
        if (glm::any(glm::greaterThanEqual(pos, mSize))) {
            throw AException("OUTOFBOUNDS");
        }
        return *mCells[pos.y * mSize.x + pos.x];
    }

    auto operator[](formula::Range range) const {

examples/7guis/cells/src/AST.cpp

7GUIs Cells - Spreadsheet processor (Excel).

const T& expect(const Variant& variant) {
    if (std::holds_alternative<T>(variant)) {
        return std::get<T>(variant);
    }
    throw AException("VALUE {}"_format(AClass<T>::name()).uppercase());
}

struct BinaryOperatorNode : public INode {
    _unique<INode> left;
    _unique<INode> right;

examples/7guis/cells/src/Tokens.cpp

7GUIs Cells - Spreadsheet processor (Excel).

                        t->reverseByte();
                        out << token::Identifier { t->readStringWhile([](char c) -> bool { return std::isalnum(c); }) };
                        continue;
                    }
                    throw AException("UNEXPECTED {}"_format(c));
            }
        }
    } catch (const AEOFException&) {}
    return out;
}

examples/7guis/cells/src/Functions.cpp

7GUIs Cells - Spreadsheet processor (Excel).

            } },
        { "IF",
            [](Ctx ctx) {
              if (ctx.args.size() != 3) {
                  throw AException("ARG");
              }
              auto condition = std::get_if<double>(&ctx.args[0]);
              if (condition == nullptr) {
                  throw AException("ARG0");
              }