JWM Source Documentation
error.c
Go to the documentation of this file.
1 
10 #include "jwm.h"
11 #include "error.h"
12 #include "main.h"
13 
15 void FatalError(const char *str, ...) {
16 
17  va_list ap;
18  va_start(ap, str);
19 
20  Assert(str);
21 
22  fprintf(stderr, _("JWM: error: "));
23  vfprintf(stderr, str, ap);
24  fprintf(stderr, "\n");
25 
26  va_end(ap);
27 
28  exit(1);
29 
30 }
31 
33 void Warning(const char *str, ...) {
34 
35  va_list ap;
36  va_start(ap, str);
37 
38  Assert(str);
39 
40  WarningVA(NULL, str, ap);
41 
42  va_end(ap);
43 
44 }
45 
47 void WarningVA(const char *part, const char *str, va_list ap) {
48 
49  Assert(str);
50 
51  fprintf(stderr, _("JWM: warning: "));
52  if(part) {
53  fprintf(stderr, "%s: ", part);
54  }
55  vfprintf(stderr, str, ap);
56  fprintf(stderr, "\n");
57 
58 }
59 
65 int ErrorHandler(Display *d, XErrorEvent *e) {
66 
67 #ifdef DEBUG
68 
69  char buffer[64];
70  char code[32];
71 
72 #endif
73 
74  if(initializing) {
75  if(e->request_code == X_ChangeWindowAttributes
76  && e->error_code == BadAccess) {
77  FatalError(_("display is already managed"));
78  }
79  }
80 
81 #ifdef DEBUG
82 
83  if(!e) {
84  fprintf(stderr, "XError: [no information]\n");
85  return 0;
86  }
87 
88  XGetErrorText(display, e->error_code, buffer, sizeof(buffer));
89  Debug("XError: %s", buffer);
90 
91  snprintf(code, sizeof(code), "%d", e->request_code);
92  XGetErrorDatabaseText(display, "XRequest", code, "?",
93  buffer, sizeof(buffer));
94  Debug(" Request Code: %d (%s)", e->request_code, buffer);
95  Debug(" Minor Code: %d", e->minor_code);
96  Debug(" Resource ID: 0x%lx", (unsigned long)e->resourceid);
97  Debug(" Error Serial: %lu", (unsigned long)e->serial);
98 
99 #if 1
100  ShowCheckpoint();
101 #endif
102 
103 #endif
104 
105  return 0;
106 
107 }

joewing.net / Projects / JWM