mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
straightforward port of rust mockup code
This commit is contained in:
parent
ef74fafc03
commit
f694f43d7d
2 changed files with 194 additions and 0 deletions
57
src/libutil/error.hh
Normal file
57
src/libutil/error.hh
Normal file
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hh"
|
||||
#include <string>
|
||||
#include <optional>
|
||||
// #include <boost/format.hpp>
|
||||
|
||||
using std::string;
|
||||
using std::optional;
|
||||
// using boost::format;
|
||||
|
||||
namespace nix {
|
||||
|
||||
enum ErrLevel
|
||||
{ elWarning
|
||||
, elError
|
||||
};
|
||||
|
||||
class ColumnRange {
|
||||
public:
|
||||
unsigned int start;
|
||||
unsigned int len;
|
||||
};
|
||||
|
||||
class ErrLine {
|
||||
public:
|
||||
int lineNumber;
|
||||
optional<ColumnRange> columnRange;
|
||||
optional<string> prevLineOfCode;
|
||||
string errLineOfCode;
|
||||
optional<string> nextLineOfCode;
|
||||
};
|
||||
|
||||
class NixCode {
|
||||
public:
|
||||
optional<string> nixFile;
|
||||
optional<ErrLine> errLine;
|
||||
};
|
||||
|
||||
|
||||
class ErrorInfo {
|
||||
public:
|
||||
ErrLevel level;
|
||||
string errName;
|
||||
string description;
|
||||
string toolName;
|
||||
optional<NixCode> nixCode;
|
||||
string hint;
|
||||
};
|
||||
|
||||
string showErrLine(ErrLine &errLine);
|
||||
|
||||
void print_code_lines(string &prefix, NixCode &nix_code);
|
||||
|
||||
void print_error(ErrorInfo &einfo);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue