Mercurial > molko
diff libmlk-rpg/mlk/rpg/message.c @ 486:d6757c30658e
core: rework errors
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 28 Feb 2023 13:04:13 +0100 |
parents | 6c06c82d276a |
children | f2d3c5a97884 |
line wrap: on
line diff
--- a/libmlk-rpg/mlk/rpg/message.c Tue Feb 28 08:40:35 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.c Tue Feb 28 13:04:13 2023 +0100 @@ -58,12 +58,13 @@ assert(msg); unsigned int maxw = 0, w = 0; + int err; for (size_t i = 0; i < msg->linesz; ++i) { if (!msg->lines[i]) continue; - if (mlk_font_query(THEME(msg)->fonts[THEME_FONT_INTERFACE], msg->lines[i], &w, NULL) < 0) - mlk_panic(); + if ((err = mlk_font_query(THEME(msg)->fonts[THEME_FONT_INTERFACE], msg->lines[i], &w, NULL)) < 0) + mlk_panic(err); if (w > maxw) maxw = w; } @@ -88,12 +89,13 @@ const struct theme *theme = THEME(msg); struct label label; unsigned int lw, lh; + int err; for (size_t i = 0; i < msg->linesz; ++i) { if (!msg->lines[i]) continue; - if (mlk_font_query(theme->fonts[THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh) < 0) - mlk_panic(); + if ((err = mlk_font_query(theme->fonts[THEME_FONT_INTERFACE], msg->lines[i], &lw, &lh)) < 0) + mlk_panic(err); label.theme = theme; label.x = theme->padding; @@ -237,7 +239,7 @@ assert(msg); struct mlk_texture tex; - int x, y; + int x, y, err; unsigned int w, h; if (msg->w == 0 || msg->h == 0) { @@ -245,8 +247,8 @@ return; } - if (mlk_texture_new(&tex, msg->w, msg->h) < 0) - mlk_panic(); + if ((err = mlk_texture_new(&tex, msg->w, msg->h)) < 0) + mlk_panic(err); MLK_PAINTER_BEGIN(&tex); draw_frame(msg);