1
0
mirror of synced 2025-01-19 01:24:15 +01:00

impr: Show full error message for custom data inspector row errors

This commit is contained in:
WerWolv 2024-06-08 13:40:39 +02:00
parent e954d49c29
commit 2ef256ee74
3 changed files with 30 additions and 8 deletions

View File

@ -514,7 +514,7 @@ namespace ImGuiExt {
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0, 0, 0, 0));
PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0, 0, 0, 0));
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, GetStyle().FramePadding.y));
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F);
PushStyleColor(ImGuiCol_Text, iconColor);
@ -522,7 +522,7 @@ namespace ImGuiExt {
PopStyleColor();
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
SetNextWindowSizeConstraints(ImVec2(GetTextLineHeight() * 25, 0), ImVec2(GetTextLineHeight() * 25, FLT_MAX));
SetNextWindowSizeConstraints(ImVec2(GetTextLineHeight() * 25, 0), ImVec2(GetTextLineHeight() * 35, FLT_MAX));
BeginTooltip();
TextFormattedWrapped("{}", text);
EndTooltip();

View File

@ -682,6 +682,7 @@
"hex.builtin.view.constants.row.desc": "Description",
"hex.builtin.view.constants.row.name": "Name",
"hex.builtin.view.constants.row.value": "Value",
"hex.builtin.view.data_inspector.execution_error": "Custom row evaluation error",
"hex.builtin.view.data_inspector.invert": "Invert",
"hex.builtin.view.data_inspector.name": "Data Inspector",
"hex.builtin.view.data_inspector.no_data": "No bytes selected",

View File

@ -170,13 +170,13 @@ namespace hex::plugin::builtin {
};
// Insert the inspector into the list
m_workData.push_back({
m_workData.emplace_back(
pattern->getDisplayName(),
displayFunction,
editingFunction,
false,
wolv::util::toUTF8String(filePath) + ":" + pattern->getVariableName()
});
);
AchievementManager::unlockAchievement("hex.builtin.achievement.patterns", "hex.builtin.achievement.patterns.data_inspector.name");
} catch (const pl::core::err::EvaluatorError::Exception &error) {
@ -184,11 +184,32 @@ namespace hex::plugin::builtin {
}
}
} else {
const auto& error = m_runtime.getEvalError();
std::string errorMessage;
if (const auto &compileErrors = m_runtime.getCompileErrors(); !compileErrors.empty()) {
for (const auto &error : compileErrors) {
errorMessage += hex::format("{}\n", error.format());
}
} else if (const auto &evalError = m_runtime.getEvalError(); evalError.has_value()) {
errorMessage += hex::format("{}:{} {}\n", evalError->line, evalError->column, evalError->message);
}
log::error("Failed to execute custom inspector file '{}'!", wolv::util::toUTF8String(filePath));
if (error.has_value())
log::error("{}", error.value().what());
auto displayFunction = [errorMessage = std::move(errorMessage)] {
ImGuiExt::HelpHover(
errorMessage.c_str(),
"hex.builtin.view.data_inspector.execution_error"_lang,
ImGuiExt::GetCustomColorU32(ImGuiCustomCol_LoggerError)
);
return errorMessage;
};
m_workData.emplace_back(
wolv::util::toUTF8String(filePath.filename()),
std::move(displayFunction),
std::nullopt,
false,
wolv::util::toUTF8String(filePath)
);
}
}
}