#ifndef TOOLS_GN_ERR_H_
#define TOOLS_GN_ERR_H_
#include <string>
#include <vector>
#include "tools/gn/location.h"
#include "tools/gn/token.h"
class ParseNode;
class Value;
class Err {
public:
typedef std::vector<LocationRange> RangeList;
Err();
Err(const Location& location,
const std::string& msg,
const std::string& help = std::string());
Err(const LocationRange& range,
const std::string& msg,
const std::string& help = std::string());
Err(const Token& token,
const std::string& msg,
const std::string& help_text = std::string());
Err(const ParseNode* node,
const std::string& msg,
const std::string& help_text = std::string());
Err(const Value& value,
const std::string msg,
const std::string& help_text = std::string());
~Err();
bool has_error() const { return has_error_; }
const Location& location() const { return location_; }
const std::string& message() const { return message_; }
const std::string& help_text() const { return help_text_; }
void AppendRange(const LocationRange& range) { ranges_.push_back(range); }
const RangeList& ranges() const { return ranges_; }
void AppendSubErr(const Err& err);
void PrintToStdout() const;
private:
void InternalPrintToStdout(bool is_sub_err) const;
bool has_error_;
Location location_;
std::vector<LocationRange> ranges_;
std::string message_;
std::string help_text_;
std::vector<Err> sub_errs_;
};
#endif