From 06d9a3d2f59ce923c20e35cdabd65f0f4e0554f5 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 13 Oct 2019 07:08:02 +0200 Subject: [PATCH] filter-transform: Catch and log exceptions --- source/filters/filter-transform.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source/filters/filter-transform.cpp b/source/filters/filter-transform.cpp index c0bec74..e441c0b 100644 --- a/source/filters/filter-transform.cpp +++ b/source/filters/filter-transform.cpp @@ -238,8 +238,12 @@ obs_properties_t* filter::transform::transform_factory::get_properties(void*) no obs_property_set_long_description(p, D_TRANSLATE(D_DESC(S_MIPGENERATOR_INTENSITY))); return pr; +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return nullptr; } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); + return nullptr; } bool filter::transform::transform_factory::modified_properties(obs_properties_t* pr, obs_property_t*, @@ -264,12 +268,17 @@ bool filter::transform::transform_factory::modified_properties(obs_properties_t* obs_property_set_visible(obs_properties_get(pr, S_MIPGENERATOR_INTENSITY), mipmappingVisible); return true; +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } void* filter::transform::transform_factory::create(obs_data_t* data, obs_source_t* source) noexcept try { return new transform_instance(data, source); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return nullptr; } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); return nullptr; @@ -277,48 +286,68 @@ void* filter::transform::transform_factory::create(obs_data_t* data, obs_source_ void filter::transform::transform_factory::destroy(void* ptr) noexcept try { delete reinterpret_cast(ptr); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } uint32_t filter::transform::transform_factory::get_width(void* ptr) noexcept try { return reinterpret_cast(ptr)->get_width(); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return 0; } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); + return 0; } uint32_t filter::transform::transform_factory::get_height(void* ptr) noexcept try { return reinterpret_cast(ptr)->get_height(); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); + return 0; } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); + return 0; } void filter::transform::transform_factory::update(void* ptr, obs_data_t* data) noexcept try { reinterpret_cast(ptr)->update(data); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } void filter::transform::transform_factory::activate(void* ptr) noexcept try { reinterpret_cast(ptr)->activate(); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } void filter::transform::transform_factory::deactivate(void* ptr) noexcept try { reinterpret_cast(ptr)->deactivate(); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } void filter::transform::transform_factory::video_tick(void* ptr, float time) noexcept try { reinterpret_cast(ptr)->video_tick(time); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } void filter::transform::transform_factory::video_render(void* ptr, gs_effect_t* effect) noexcept try { reinterpret_cast(ptr)->video_render(effect); +} catch (const std::exception& ex) { + P_LOG_ERROR("Unexpected exception in function '%s': %s.", __FUNCTION_NAME__, ex.what()); } catch (...) { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); }