|
Packit Service |
7770af |
#ifndef SASS_ERROR_HANDLING_H
|
|
Packit Service |
7770af |
#define SASS_ERROR_HANDLING_H
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
#include <string>
|
|
Packit Service |
7770af |
#include <sstream>
|
|
Packit Service |
7770af |
#include <stdexcept>
|
|
Packit Service |
7770af |
#include "position.hpp"
|
|
Packit Service |
7770af |
#include "ast_fwd_decl.hpp"
|
|
Packit Service |
7770af |
#include "sass/functions.h"
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
namespace Sass {
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
struct Backtrace;
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
namespace Exception {
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
const std::string def_msg = "Invalid sass detected";
|
|
Packit Service |
7770af |
const std::string def_op_msg = "Undefined operation";
|
|
Packit Service |
7770af |
const std::string def_op_null_msg = "Invalid null operation";
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class Base : public std::runtime_error {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
std::string msg;
|
|
Packit Service |
7770af |
std::string prefix;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
ParserState pstate;
|
|
Packit Service |
7770af |
std::vector<Sass_Import_Entry>* import_stack;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
Base(ParserState pstate, std::string msg = def_msg, std::vector<Sass_Import_Entry>* import_stack = 0);
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return prefix.c_str(); }
|
|
Packit Service |
7770af |
virtual const char* what() const throw() { return msg.c_str(); }
|
|
Packit Service |
7770af |
virtual ~Base() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidSass : public Base {
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidSass(ParserState pstate, std::string msg);
|
|
Packit Service |
7770af |
virtual ~InvalidSass() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidParent : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
Selector_Ptr parent;
|
|
Packit Service |
7770af |
Selector_Ptr selector;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidParent(Selector_Ptr parent, Selector_Ptr selector);
|
|
Packit Service |
7770af |
virtual ~InvalidParent() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class MissingArgument : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
std::string fn;
|
|
Packit Service |
7770af |
std::string arg;
|
|
Packit Service |
7770af |
std::string fntype;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
MissingArgument(ParserState pstate, std::string fn, std::string arg, std::string fntype);
|
|
Packit Service |
7770af |
virtual ~MissingArgument() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidArgumentType : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
std::string fn;
|
|
Packit Service |
7770af |
std::string arg;
|
|
Packit Service |
7770af |
std::string type;
|
|
Packit Service |
7770af |
const Value_Ptr value;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidArgumentType(ParserState pstate, std::string fn, std::string arg, std::string type, const Value_Ptr value = 0);
|
|
Packit Service |
7770af |
virtual ~InvalidArgumentType() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidVarKwdType : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
std::string name;
|
|
Packit Service |
7770af |
const Argument_Ptr arg;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidVarKwdType(ParserState pstate, std::string name, const Argument_Ptr arg = 0);
|
|
Packit Service |
7770af |
virtual ~InvalidVarKwdType() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidSyntax : public Base {
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidSyntax(ParserState pstate, std::string msg, std::vector<Sass_Import_Entry>* import_stack = 0);
|
|
Packit Service |
7770af |
virtual ~InvalidSyntax() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
/* common virtual base class (has no pstate) */
|
|
Packit Service |
7770af |
class OperationError : public std::runtime_error {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
std::string msg;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
OperationError(std::string msg = def_op_msg)
|
|
Packit Service |
7770af |
: std::runtime_error(msg), msg(msg)
|
|
Packit Service |
7770af |
{};
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return "Error"; }
|
|
Packit Service |
7770af |
virtual const char* what() const throw() { return msg.c_str(); }
|
|
Packit Service |
7770af |
virtual ~OperationError() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class ZeroDivisionError : public OperationError {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
const Expression& lhs;
|
|
Packit Service |
7770af |
const Expression& rhs;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
ZeroDivisionError(const Expression& lhs, const Expression& rhs);
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return "ZeroDivisionError"; }
|
|
Packit Service |
7770af |
virtual ~ZeroDivisionError() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class DuplicateKeyError : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
const Map& dup;
|
|
Packit Service |
7770af |
const Expression& org;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
DuplicateKeyError(const Map& dup, const Expression& org);
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return "Error"; }
|
|
Packit Service |
7770af |
virtual ~DuplicateKeyError() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class TypeMismatch : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
const Expression& var;
|
|
Packit Service |
7770af |
const std::string type;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
TypeMismatch(const Expression& var, const std::string type);
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return "Error"; }
|
|
Packit Service |
7770af |
virtual ~TypeMismatch() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidValue : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
const Expression& val;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidValue(const Expression& val);
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return "Error"; }
|
|
Packit Service |
7770af |
virtual ~InvalidValue() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class StackError : public Base {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
const AST_Node& node;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
StackError(const AST_Node& node);
|
|
Packit Service |
7770af |
virtual const char* errtype() const { return "SystemStackError"; }
|
|
Packit Service |
7770af |
virtual ~StackError() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class IncompatibleUnits : public OperationError {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
// const Sass::UnitType lhs;
|
|
Packit Service |
7770af |
// const Sass::UnitType rhs;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
IncompatibleUnits(const Number& lhs, const Number& rhs);
|
|
Packit Service |
7770af |
IncompatibleUnits(const UnitType lhs, const UnitType rhs);
|
|
Packit Service |
7770af |
virtual ~IncompatibleUnits() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class UndefinedOperation : public OperationError {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
Expression_Ptr_Const lhs;
|
|
Packit Service |
7770af |
Expression_Ptr_Const rhs;
|
|
Packit Service |
7770af |
const std::string op;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
UndefinedOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, const std::string& op);
|
|
Packit Service |
7770af |
// virtual const char* errtype() const { return "Error"; }
|
|
Packit Service |
7770af |
virtual ~UndefinedOperation() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class InvalidNullOperation : public UndefinedOperation {
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
InvalidNullOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, const std::string& op);
|
|
Packit Service |
7770af |
virtual ~InvalidNullOperation() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class AlphaChannelsNotEqual : public OperationError {
|
|
Packit Service |
7770af |
protected:
|
|
Packit Service |
7770af |
Expression_Ptr_Const lhs;
|
|
Packit Service |
7770af |
Expression_Ptr_Const rhs;
|
|
Packit Service |
7770af |
const std::string op;
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
AlphaChannelsNotEqual(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, const std::string& op);
|
|
Packit Service |
7770af |
// virtual const char* errtype() const { return "Error"; }
|
|
Packit Service |
7770af |
virtual ~AlphaChannelsNotEqual() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
class SassValueError : public Base {
|
|
Packit Service |
7770af |
public:
|
|
Packit Service |
7770af |
SassValueError(ParserState pstate, OperationError& err);
|
|
Packit Service |
7770af |
virtual ~SassValueError() throw() {};
|
|
Packit Service |
7770af |
};
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
}
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
void warn(std::string msg, ParserState pstate);
|
|
Packit Service |
7770af |
void warn(std::string msg, ParserState pstate, Backtrace* bt);
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
void deprecated_function(std::string msg, ParserState pstate);
|
|
Packit Service |
7770af |
void deprecated(std::string msg, std::string msg2, ParserState pstate);
|
|
Packit Service |
7770af |
void deprecated_bind(std::string msg, ParserState pstate);
|
|
Packit Service |
7770af |
// void deprecated(std::string msg, ParserState pstate, Backtrace* bt);
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
void error(std::string msg, ParserState pstate);
|
|
Packit Service |
7770af |
void error(std::string msg, ParserState pstate, Backtrace* bt);
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
}
|
|
Packit Service |
7770af |
|
|
Packit Service |
7770af |
#endif
|