[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/igc fda6f96c98c: Make IGC_CHECK_RES error messages more specific
From: |
Stefan Kangas |
Subject: |
feature/igc fda6f96c98c: Make IGC_CHECK_RES error messages more specific |
Date: |
Tue, 21 Jan 2025 18:29:25 -0500 (EST) |
branch: feature/igc
commit fda6f96c98ca41fde067f658749f96fb695667c5
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>
Make IGC_CHECK_RES error messages more specific
* src/igc.c (result_string): New function returning strings describing
errors. The descriptions are based on the "Error handling" chapter in
the MPS Reference, and are adapted to be somewhat user-facing.
(check_res): Use it.
---
src/igc.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/igc.c b/src/igc.c
index 158684ca0c1..257e7dc53f7 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -252,13 +252,40 @@ enum igc_state
static enum igc_state igc_state = IGC_STATE_INITIAL;
static void set_state (enum igc_state state);
+static const char *
+result_string (mps_res_t res)
+{
+ switch (res)
+ {
+ case MPS_RES_OK:
+ return "operation succeeded";
+ case MPS_RES_FAIL:
+ return "operation failed";
+ case MPS_RES_IO:
+ return "an I/O error occurred in the telemetry system";
+ case MPS_RES_LIMIT:
+ return "an internal limitation was exceeded";
+ case MPS_RES_MEMORY:
+ return "out of memory";
+ case MPS_RES_RESOURCE:
+ return "a needed resource could not be obtained";
+ case MPS_RES_UNIMPL:
+ return "operation is not implemented (this is probably a bug)";
+ case MPS_RES_COMMIT_LIMIT:
+ return "the arena's commit limit would be exceeded";
+ case MPS_RES_PARAM:
+ return "an invalid parameter was passed (this is probably a bug)";
+ }
+ return "unknown error";
+}
+
static void
check_res (const char *file, unsigned line, mps_res_t res)
{
if (res != MPS_RES_OK)
{
- fprintf (stderr, "\r\n%s:%u: Emacs fatal error: MPS error code %d\r\n",
- file, line, res);
+ fprintf (stderr, "\r\n%s:%u: Emacs fatal error: MPS error %d: %s\r\n",
+ file, line, res, result_string (res));
set_state (IGC_STATE_DEAD);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- feature/igc fda6f96c98c: Make IGC_CHECK_RES error messages more specific,
Stefan Kangas <=