creator-level saving new files in fat
[quarnos.git] / manes / error.cpp
blob26bda5b4f0de3809b816890162e0d953ad6f72b1
1 #include "arch/x86/console.h"
2 #include "arch/x86/hlt.h"
3 #include "error.h"
4 #include "libs/string.h"
5 using namespace manes;
7 error::error(const char *msg) : base_err(0), er_message(msg) {}
8 error::error(error *er) : base_err(er) {}
9 error::error(error *er, const char *msg) : base_err(er), er_message(msg) {}
11 void error::critical() {
12 x = y = 0;
13 er_print("Critical Quarn OS error has occurred!\n", arch::scr_red);
14 for (error *er = this; er; er = er->base_err)
15 er_print(er->er_message, arch::scr_red);
16 er_print("\nSystem is halted.", arch::scr_red);
18 halt_forever();
21 void error::assertion() {
22 #if DEBUG_MODE == CONF_YES
23 x = 0;
24 y = arch::last_y + 1;
25 er_print("Assertion failed!\n", arch::scr_yellow);
26 for (error *er = this; er; er = er->base_err)
27 er_print(er->er_message, arch::scr_yellow);
28 er_print("\nPress any key to continue...", arch::scr_yellow);
29 wait_key();
30 #endif
33 #if DEBUG_MODE == CONF_YES
34 extern unsigned int last_call0;
35 extern unsigned int last_call1;
36 #endif
38 void error::debug() {
39 #if DEBUG_MODE == CONF_YES
40 x = 0;
41 y = arch::last_y + 1;
42 er_print("(", arch::scr_darkgray);
43 for (error *er = this; er; er = er->base_err)
44 er_print(er->er_message, arch::scr_darkgray);
45 er_print(((string)" [last call: 0x" + string(last_call0,true) + ", 0x" + string(last_call1,true) + "]"),arch::scr_darkgray);
46 er_print(")", arch::scr_darkgray);
47 wait_key();
48 #endif
51 void error::er_print(const char *message, arch::scr_color color) {
52 assert("error: null error message", message == 0);
54 for (int i = 0; message[i] != 0; i++) {
56 if (message[i] == '\n') {
57 y++;
58 x = 0;
59 } else {
60 arch::screen_print(message[i],color,x,y);
61 x++;
64 y += x / arch::scr_width;
65 x = x % arch::scr_width;