Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
diagnostic_error.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * DiagnosticError — a failure that names itself to a driver: the prose a
5 * person reads, and beside it the lines a program reads.
6 *
7 * An entry point prints `Error: <what()>` for any exception. For one of these
8 * it then prints each of diagnostic_lines() on a line of its own, `key:
9 * value`, the first of them `diagnostic: <code>` -- so a driver routes on the
10 * code while a reader still gets the sentence, and the entry point needs to
11 * know nothing about what failed or which lines that failure has to add.
12 *
13 * A std::runtime_error, so every catch of the base class still sees the prose.
14 */
15
16#include <stdexcept>
17#include <string>
18#include <vector>
19
20namespace q3 {
21
22class DiagnosticError : public std::runtime_error {
23 public:
24 using std::runtime_error::runtime_error;
25
26 /// The lines an entry point prints after the prose, in order; never empty.
27 [[nodiscard]] virtual std::vector<std::string> diagnostic_lines() const = 0;
28};
29
30} // namespace q3
virtual std::vector< std::string > diagnostic_lines() const =0
The lines an entry point prints after the prose, in order; never empty.