nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
diagnostics.hpp
Go to the documentation of this file.
1
3// toolboxes/builtin/include/nk/builtin/programming/errors/diagnostics.hpp
4#pragma once
5
6#include <memory_resource>
7#include <nk/value/span.hpp>
8#include <nk/value/value.hpp>
9
10namespace nk {
11class Engine;
12}
13
14namespace nk::runtime {
15
18
19void registerDiagnosticsRuntime(Engine &engine);
20
21// ── error() ───────────────────────────────────────────────────
22
36[[noreturn]] void error(Span<const Value> args);
37
46void warning(Engine &engine, Span<const Value> args); // lint: engine-io
47
49struct LastWarn {
50 std::string msg;
51 std::string id;
52};
53
62
71void lastwarnSet(const std::string &msg, const std::string &id);
72
82Value mexception(Span<const Value> args, std::pmr::memory_resource *mr = nullptr);
83
84// ── rethrow(ME) / throw(ME) ──────────────────────────────────────────
85
93[[noreturn]] void rethrowStruct(const Value &me);
94
109
110
112} // namespace nk::runtime
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
void rethrowStruct(const Value &me)
Rethrow from an MException struct (rethrow(me) / throw(me)).
void error(Span< const Value > args)
Throw an Error (error(...)).
void lastwarnSet(const std::string &msg, const std::string &id)
Overwrite the most-recent warning state.
void assertCond(Span< const Value > args)
Throw on a false condition (assert(...)).
Value mexception(Span< const Value > args, std::pmr::memory_resource *mr=nullptr)
Build an MException-like struct (me = MException(id, msg, args...)).
void warning(Engine &engine, Span< const Value > args)
Engine-stateful warning (warning(...)).
LastWarn lastwarnGet()
Read most-recent warning state ([msg, id] = lastwarn()).
Snapshot of the most-recent warning.
std::string id
Last warning's identifier ("" if unset).
std::string msg
Last warning's formatted message.