1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00
TegraExplorer/source/err.c

62 lines
1.9 KiB
C
Raw Normal View History

#include "err.h"
#include "gfx/gfx.h"
#include "hid/hid.h"
#include "gfx/gfxutils.h"
2020-12-25 20:16:24 +00:00
const char *TEErrors[] = {
"I/O ERROR",
"NO DISK",
"NOT READY",
"NO FILE",
"NO PATH",
"PATH INVALID",
"ACCESS DENIED",
"ACCESS DENIED",
"INVALID PTR",
"PROTECTED",
"INVALID DRIVE",
"NO MEM",
"NO FAT",
2020-12-25 20:16:24 +00:00
"MKFS ABORT",
[TE_ERR_UNIMPLEMENTED - 1] = "Unimplemented",
[TE_EXCEPTION_RESET - 1] = "E Reset",
[TE_EXCEPTION_UNDEFINED - 1] = "E Undefined",
[TE_EXCEPTION_PREF_ABORT - 1] = "E Pref abort",
[TE_EXCEPTION_DATA_ABORT - 1] = "E Data abort",
2020-12-26 00:05:33 +00:00
[TE_ERR_SAME_LOC - 1] = "Same copy location",
2020-12-26 21:24:41 +00:00
[TE_ERR_KEYDUMP_FAIL - 1] = "Keydump failed",
[TE_ERR_PARTITION_NOT_FOUND - 1] = "Failed to find partition",
2020-12-30 21:51:07 +00:00
[TE_ERR_PATH_IN_PATH - 1] = "Can't move/copy folder into itself",
[TE_ERR_EMMC_READ_FAIL - 1] = "Emmc/Emummc read failed",
2020-12-31 11:55:26 +00:00
[TE_ERR_EMMC_WRITE_FAIL - 1] = "Emmc/Emummc write failed",
2020-12-30 21:51:07 +00:00
[TE_ERR_NO_SD - 1] = "No sd detected",
2020-12-31 11:55:26 +00:00
[TE_ERR_FILE_TOO_BIG_FOR_DEST - 1] = "File is too big for dest",
};
const char *GetErrStr(u32 err){
--err; // obv error codes cannot be 0
2020-12-25 20:16:24 +00:00
if (err >= 0 && err < ARRAY_SIZE(TEErrors))
return TEErrors[err];
return "(Unknown)";
}
#define lx 256
#define ly 240
#define lenx 768
#define leny 240
void DrawError(ErrCode_t err){
2020-12-26 00:05:33 +00:00
if (err.err == 0)
return;
SETCOLOR(COLOR_ORANGE, COLOR_DARKGREY);
gfx_box(lx, ly, lx + lenx, ly + leny, COLOR_ORANGE);
gfx_boxGrey(lx + 16, ly + 16, lx + lenx - 16, ly + leny - 16, 0x33);
gfx_con_setpos(lx + ((lenx - 17 * 16) / 2), ly + 32);
gfx_printf("An error occured!\n\n%bErr : %d\nLine: %d\nFile: %s\nDesc: %s%b", lx + 48, err.err, err.loc, err.file, GetErrStr(err.err), 0);
gfx_con_setpos(lx + ((lenx - 19 * 16) / 2), ly + leny - 48);
gfx_printf("Press A to continue");
hidWaitMask((JoyA | JoyB));
}