Skip to content

Commit

Permalink
SUKU error string prining implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
SukuWc committed Aug 30, 2024
1 parent a12f357 commit 13f1fa0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions grid_common/grid_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ uint32_t grid_lua_dostring(struct grid_lua_model* lua, char* code) {
// remove the code from the stack
} else {
// grid_platform_printf("LUA not OK: %s \r\n", code);
stpncpy(lua->stde, lua_tostring(lua->L, -1), lua->stde_len);
grid_lua_clear_stde(lua);
stpncpy(lua->stde, lua_tostring(lua->L, -1), lua->stde_len - 1);
is_ok = 0;
}

Expand All @@ -113,7 +114,8 @@ uint32_t grid_lua_dostring(struct grid_lua_model* lua, char* code) {
// grid_platform_printf("LUA not OK: %s\r\n", code);
// grid_port_debug_printf("LUA not OK 2");

stpncpy(lua->stde, lua_tostring(lua->L, -1), lua->stde_len);
grid_lua_clear_stde(lua);
stpncpy(lua->stde, lua_tostring(lua->L, -1), lua->stde_len - 1);
is_ok = 0;

lua_pop(lua->L, 1); // Remove error message from the stack
Expand Down
2 changes: 1 addition & 1 deletion grid_common/grid_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end"
#define GRID_LUA_STDO_LENGTH 100
#define GRID_LUA_STDI_LENGTH 100

#define GRID_LUA_STDE_LENGTH 100
#define GRID_LUA_STDE_LENGTH 400

struct grid_lua_model {

Expand Down
2 changes: 1 addition & 1 deletion grid_common/grid_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ void grid_port_debug_printf(char const* fmt, ...) {

va_list ap;

const int len = 150;
const int len = 300;
const char truncation[] = " ... (message truncated)";

char temp[len];
Expand Down
4 changes: 3 additions & 1 deletion grid_common/grid_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ uint32_t grid_ui_event_render_action(struct grid_ui_event* eve, char* target_str

if (0 == grid_lua_dostring(&grid_lua_state, &temp[code_start + 6])) {
grid_port_debug_printf("LUA not OK! EL: %d EV: %d MSG: %s", eve->parent->index, eve->type, grid_lua_get_error_string(&grid_lua_state));
};
grid_platform_printf("LUA not OK! EL: %d EV: %d MSG: %s\r\n", eve->parent->index, eve->type, grid_lua_get_error_string(&grid_lua_state));
grid_lua_clear_stde(&grid_lua_state);
}

uint32_t code_stdo_length = strlen(grid_lua_get_output_string(&grid_lua_state));

Expand Down

0 comments on commit 13f1fa0

Please sign in to comment.