From 7213c769e074f544f790ae73fac350c6cff6488f Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 30 Sep 2024 11:54:33 +0200 Subject: [PATCH] Updated Error Handling (markdown) --- Error-Handling.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Error-Handling.md b/Error-Handling.md index acc4235..f0c8163 100644 --- a/Error-Handling.md +++ b/Error-Handling.md @@ -6,6 +6,7 @@ Since Dear ImGui 1.91.3 we provide way to configure how to handle _SOME_ recover - Error recovery is provided as a way to facilitate recovery from errors in e.g. scripting languages, or after specific exceptions handlers. - Error recovery is not perfect nor guaranteed! You are not supposed to rely on it in the course of a normal application run. +- By design, we do NOT allow error recovery to be 100% silent. One of the three options needs to be checked. - Always ensure that on programmers seat you have at minimum Asserts or Tooltips enabled when making direct imgui API call! Otherwise it would severely hinder your ability to catch and correct mistakes! Typical scenarios: @@ -19,7 +20,7 @@ Typical scenarios: - Disable Asserts `io.ConfigErrorRecoveryEnableAssert=false` but keep Tooltips visible. - Recoverable errors will be visible in an error tooltip. - The error tooltip will allow user to enable asserts. -- THIS IMPLICITLY RELY ON RECOVERY BEING FUNCTIONAL. A FEW CASES MIGHT PROBABLY STILL CRASH/ASSERTS. +- This implicitly rely on functional recovery. A few cases might probably still crash/assert. If this works well, we may make it the default in future versions. #### (3) Non-programmer seats: what you might want to setup: - Use `io.ConfigErrorRecoveryEnableAssert=false`, but make sure log entries are well visible or reported somewhere. @@ -63,13 +64,21 @@ bool ConfigErrorRecoveryEnableTooltip; // = true // Enable toolti e.g. ```cpp ImGuiErrorRecoveryState state; +ImGui::ErrorRecoveryStoreState(&state); +.... run scripting code +ImGui::ErrorRecoveryTryToRecoverState(&state); +``` + +Exception handling: +```cpp +ImGuiErrorRecoveryState state; +ImGui::ErrorRecoveryStoreState(&state); try { - ImGui::ErrorRecoveryStoreState(&state); -.... run code + .... run code } catch { - ImGui::ErrorRecoveryTryToRecoverState(&state); + ImGui::ErrorRecoveryTryToRecoverState(&state); } ``` \ No newline at end of file