载入中...
搜索中...
未找到
ScriptError.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4
5#include <squirrel.h>
6
7#include <string>
8#include <vector>
9
10namespace eve::script {
11
32
35 std::string source;
36 std::string function;
37 int line = -1;
38};
39
47 std::string message;
48 std::string source;
49 std::string function;
50 int line = -1;
51 int column = -1;
52 std::string hint;
53 std::vector<ScriptFrame> stack;
54 bool reported = false;
57 bool empty() const noexcept { return message.empty() && stack.empty(); }
58};
59
66
73
83EVENGINE_API_FOUNDATION bool parseCompileError(const std::string& text, std::string* source, int* line, int* column,
84 std::string* message);
85
92EVENGINE_API_FOUNDATION std::string sourceLineText(const std::string& sourceText, int line);
93
99EVENGINE_API_FOUNDATION std::string formatScriptError(const ScriptErrorContext& ctx);
100
106EVENGINE_API_FOUNDATION std::string formatStackTrace(const std::vector<ScriptFrame>& frames);
107
113EVENGINE_API_FOUNDATION void setLastScriptError(HSQUIRRELVM vm, ScriptErrorContext ctx);
114
121
128
134
141
142} // namespace eve::script
struct SQVM * HSQUIRRELVM
HSQUIRRELVM vm
Definition ECS.cpp:38
#define EVENGINE_API_FOUNDATION_INLINE
仅供"只有内联成员"的类型使用的组宏:拥有者 dllexport,消费方不导入。
Definition Export.h:170
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::string message
unsigned line
std::string text
std::string_view source
unsigned column
std::string formatScriptError(const ScriptErrorContext &ctx)
Formats a context into a human-readable multi-line report.
void clearLastScriptError(HSQUIRRELVM vm)
Drops any recorded error for a VM.
std::string sourceLineText(const std::string &sourceText, int line)
Extracts one 1-based line from script source text.
ScriptErrorContext takeLastScriptError(HSQUIRRELVM vm)
Consumes and clears the last recorded error for a VM.
void installScriptErrorHook(HSQUIRRELVM vm)
Install the engine's script error hook on a VM.
Definition Runtime.cpp:320
std::string formatLastScriptError(HSQUIRRELVM vm)
Formats the last captured error for a VM without consuming it.
ScriptErrorContext captureCompileError(HSQUIRRELVM vm)
Captures the last compilation error recorded by the VM.
const ScriptErrorContext * peekLastScriptError(HSQUIRRELVM vm)
Peeks at the last recorded error for a VM without clearing it.
bool parseCompileError(const std::string &text, std::string *source, int *line, int *column, std::string *message)
Parses the ssq compile message "Compile error at source:line:column msg".
void setLastScriptError(HSQUIRRELVM vm, ScriptErrorContext ctx)
Records the last error for a VM (thread-local, synchronous consumers).
std::string formatStackTrace(const std::vector< ScriptFrame > &frames)
Formats just the call-stack portion of a context.
ScriptErrorContext captureScriptError(HSQUIRRELVM vm)
Captures the pending runtime error from inside the Squirrel error handler.
Structured snapshot of a script error: message, throw site and stack.
Definition ScriptError.h:46
std::string function
Function of the throwing frame.
Definition ScriptError.h:49
bool empty() const noexcept
True when no error payload was captured.
Definition ScriptError.h:57
std::string hint
Optional source snippet shown under the message.
Definition ScriptError.h:52
std::string message
Raw error value ("kaboom", "42", ...).
Definition ScriptError.h:47
std::vector< ScriptFrame > stack
Call stack, innermost frame first.
Definition ScriptError.h:53
std::string source
Source of the throwing frame.
Definition ScriptError.h:48
One call-stack frame captured while the script error is still live.
Definition ScriptError.h:34
std::string function
Function name, when Squirrel debug info knows it.
Definition ScriptError.h:36
std::string source
Source name of the frame ("main.nut", "buffer", ...).
Definition ScriptError.h:35