ecere: Fixed error messages
authorJerome St-Louis <jerome@ecere.com>
Wed, 2 Apr 2014 07:12:53 +0000 (03:12 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 2 Apr 2014 07:14:28 +0000 (03:14 -0400)
compiler/bootstrap/ecere/bootstrap/System.c
ecere/src/gui/GuiApplication.ec
ecere/src/sys/System.ec

index 28efb44..bf07918 100644 (file)
@@ -595,10 +595,21 @@ void __ecereNameSpace__ecere__sys__LogErrorCode(unsigned int errorCode, char * d
 {
 if(((int)((errorCode & 0x3000) >> 12)) <= __ecereNameSpace__ecere__sys__globalSystem.errorLevel)
 {
+int cat = (((unsigned int)((errorCode & 0xFFF) >> 0)) & 0xF00) >> 8;
+int code = ((unsigned int)((errorCode & 0xFFF) >> 0)) & 0xFF;
+
 if(details)
-__ecereNameSpace__ecere__sys__Logf("System Error [%d]: %s (%s).\n", ((int)((errorCode & 0x3000) >> 12)), ((char **)((struct __ecereNameSpace__ecere__com__Array *)(((char *)__ecereNameSpace__ecere__sys__errorMessages + structSize_Instance)))->array)[((unsigned int)((errorCode & 0xFFF) >> 0))], details);
+__ecereNameSpace__ecere__sys__Logf("System Error [%d]: %s (%s).\n", ((int)((errorCode & 0x3000) >> 12)), ((char **)__extension__ ({
+char * __ecTemp1 = (((struct __ecereNameSpace__ecere__com__Instance **)((struct __ecereNameSpace__ecere__com__Array *)(((char *)__ecereNameSpace__ecere__sys__errorMessages + structSize_Instance)))->array)[cat]);
+
+((struct __ecereNameSpace__ecere__com__Array *)(__ecTemp1 + structSize_Instance));
+})->array)[code], details);
 else
-__ecereNameSpace__ecere__sys__Logf("System Error [%d]: %s.\n", ((int)((errorCode & 0x3000) >> 12)), ((char **)((struct __ecereNameSpace__ecere__com__Array *)(((char *)__ecereNameSpace__ecere__sys__errorMessages + structSize_Instance)))->array)[((unsigned int)((errorCode & 0xFFF) >> 0))]);
+__ecereNameSpace__ecere__sys__Logf("System Error [%d]: %s.\n", ((int)((errorCode & 0x3000) >> 12)), ((char **)__extension__ ({
+char * __ecTemp1 = (((struct __ecereNameSpace__ecere__com__Instance **)((struct __ecereNameSpace__ecere__com__Array *)(((char *)__ecereNameSpace__ecere__sys__errorMessages + structSize_Instance)))->array)[cat]);
+
+((struct __ecereNameSpace__ecere__com__Array *)(__ecTemp1 + structSize_Instance));
+})->array)[code]);
 }
 __ecereNameSpace__ecere__sys__globalSystem.lastErrorCode = errorCode;
 }
index 2c63e1b..b6c9e24 100644 (file)
@@ -87,15 +87,6 @@ import "Window"
 GuiApplication guiApp;
 int terminateX;
 
-static Array<String> errorMessages
-{ [
-   $"No error",
-   $"Graphics driver not supported by any user interface system",
-   $"Window creation failed",
-   $"Window graphics loading failed",
-   $"Driver/Mode switch failed"
-] };
-
 public class GuiApplication : Application
 {
    int numDrivers;
index 0a93d4e..f08239c 100644 (file)
@@ -116,15 +116,26 @@ public enum GuiErrorCode : ErrorCode
 
 static define DEFAULT_BUFFER_SIZE = 100 * MAX_F_STRING;
 
-static Array<String> errorMessages
+static Array<Array<String>> errorMessages
 { [
-   $"No error",
-   $"Memory allocation failed",
-   $"Inexistant string identifier specified",
-   $"Identic string identifier already exists",
-   $"Shared library loading failed",
-   $"File not found",
-   $"Couldn't write to file"
+   // System
+   { [
+      $"No error",
+      $"Memory allocation failed",
+      $"Inexistant string identifier specified",
+      $"Identic string identifier already exists",
+      $"Shared library loading failed",
+      $"File not found",
+      $"Couldn't write to file"
+   ] },
+   // GUI
+   { [
+      $"No error",
+      $"Graphics driver not supported by any user interface system",
+      $"Window creation failed",
+      $"Window graphics loading failed",
+      $"Driver/Mode switch failed"
+   ] }
 ] };
 
 // --- File, directory & environment manipulation ---
@@ -303,15 +314,17 @@ public void LogErrorCode(ErrorCode errorCode, char * details)
 {
    if(errorCode.level <= globalSystem.errorLevel)
    {
+      int cat = (errorCode.code & 0xF00) >> 8;
+      int code = errorCode.code & 0xFF;
       if(details)
          Logf("System Error [%d]: %s (%s).\n",
             errorCode.level,
-            errorMessages[errorCode.code],
+            errorMessages[cat][code],
             details);
       else
          Logf("System Error [%d]: %s.\n",
             errorCode.level,
-            errorMessages[errorCode.code]);
+            errorMessages[cat][code]);
    }
    globalSystem.lastErrorCode = errorCode;
 }