CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Exception.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
11
12#include <stdexcept>
13
15
16 struct AST;
17
18 // Runtime error exception class with a reference to the AST node where the error occured.
19 class ASTRuntimeError : public std::runtime_error {
20 public:
21 explicit ASTRuntimeError(const char* msg, const AST* ast);
22 explicit ASTRuntimeError(const String& msg, const AST* ast);
24
25 // Returns the AST node which caused the error.
26 [[nodiscard]] inline const AST* getAST() const { return mAST; }
27
28 // Returns the secondary list of AST nodes.
29 [[nodiscard]] inline const Vector<const AST*>& getASTAppendices() const { return mASTAppendices; }
30
31 private:
32 const AST* mAST = nullptr;
34 };
35
36 // Throws an std::runtime_error exception.
37 [[noreturn]] void runtimeErr(const char* msg);
38
39 // Throws an std::runtime_error exception.
40 [[noreturn]] void runtimeErr(const String& msg);
41
42 // Throws an ASTRuntimeError exception if 'ast' is non-null, otherwise it std::runtime_error is thrown.
43 [[noreturn]] void runtimeErr(const char* msg, const AST* ast);
44
45 // Throws an ASTRuntimeError exception if 'ast' is non-null, otherwise it std::runtime_error is thrown.
46 [[noreturn]] void runtimeErr(const String& msg, const AST* ast);
47
48 // Throws an ASTRuntimeError exception if 'ast' is non-null, otherwise it std::runtime_error is thrown.
50
51 // Throws an std::invalid_argument exception.
52 [[noreturn]] void invalidArg(const char* msg);
53
54 // Throws an std::invalid_argument exception.
55 [[noreturn]] void invalidArg(const String& msg);
56
57} // namespace CeresEngine::ShaderCompiler
Vector< const AST * > mASTAppendices
Definition Exception.hpp:33
ASTRuntimeError(const String &msg, const AST *ast, const Vector< const AST * > &astAppendices)
const AST * getAST() const
Definition Exception.hpp:26
ASTRuntimeError(const String &msg, const AST *ast)
ASTRuntimeError(const char *msg, const AST *ast)
const Vector< const AST * > & getASTAppendices() const
Definition Exception.hpp:29
const AST * mAST
Definition Exception.hpp:32
Definition AST.hpp:33
void invalidArg(const char *msg)
void runtimeErr(const char *msg)
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25