mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-03 17:39:02 +00:00
Made Lexer errors fully hidden in global scope
Also improved general ease of use with debugging use __debugbreak when an error is thrown. NOTE: Parser errors currently crash the program
This commit is contained in:
@@ -2,14 +2,41 @@ namespace LX
|
||||
{
|
||||
// Base error class for all LX thrown errors //
|
||||
// Holds nothing apart from the v-table //
|
||||
struct RuntimeError
|
||||
struct COMMON_API RuntimeError
|
||||
{
|
||||
// Default constructor which throws a breakpoint on being created //
|
||||
RuntimeError();
|
||||
|
||||
// Prints the error to the console //
|
||||
// Include Common/Console.h for printing util functions //
|
||||
virtual void PrintToConsole() const = 0;
|
||||
|
||||
// Returns a C-String of the type that was thrown //
|
||||
virtual const char* ErrorType() const = 0;
|
||||
|
||||
// Virtual destructor because of polymorphism //
|
||||
virtual ~RuntimeError() = default;
|
||||
};
|
||||
|
||||
// --- Common errors that can be thrown --- //
|
||||
|
||||
// Error thrown when there is an invalid file path //
|
||||
struct COMMON_API InvalidFilePath : public RuntimeError
|
||||
{
|
||||
// Constructor to turn the C++ types to C to expose them in DLL //
|
||||
InvalidFilePath(const std::string& _name, const std::filesystem::path& path);
|
||||
|
||||
// Prints the error to the console //
|
||||
void PrintToConsole() const;
|
||||
|
||||
// Returns the error as c-string //
|
||||
const char* ErrorType() const;
|
||||
|
||||
// Name of the file that is invalid (used for console output) //
|
||||
const char* name;
|
||||
|
||||
// The location of the file (used for console output) //
|
||||
const char* fileLocation;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user