Skip to content

Commit

Permalink
consistent error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
djowel committed Mar 25, 2024
1 parent a26ac14 commit 8a2c432
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/host/linux/skia_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ namespace

void realize(GtkGLArea* area, gpointer user_data)
{
auto error = [](char const* msg) { throw std::runtime_error(msg); };

gtk_gl_area_make_current(area);
if (gtk_gl_area_get_error(area) != nullptr)
throw std::runtime_error("Error. gtk_gl_area_get_error failed");
error("Error. gtk_gl_area_get_error failed");

view_state& state = *reinterpret_cast<view_state*>(user_data);
glClearColor(state._bkd.red, state._bkd.green, state._bkd.blue, state._bkd.alpha);
Expand All @@ -62,10 +64,10 @@ namespace
}
);
if (state._xface == nullptr)
throw std::runtime_error("Error. GLMakeNativeInterface failed");
error("Error. GLMakeNativeInterface failed");
}
if (state._ctx = GrDirectContext::MakeGL(state._xface); state._ctx == nullptr)
throw std::runtime_error("Error. GrDirectContext::MakeGL failed");
error("Error. GrDirectContext::MakeGL failed");
}

gboolean render(GtkGLArea* area, GdkGLContext* context, gpointer user_data)
Expand Down

0 comments on commit 8a2c432

Please sign in to comment.