From 18309852badcb90555d32e3e269a81873ecbd10a Mon Sep 17 00:00:00 2001 From: Katarzyna Mitrus Date: Tue, 18 Jan 2022 09:49:02 +0100 Subject: [PATCH] Update Model::reshape to rethrow currently handled exception (#9723) * Update Model::reshape to rethrow the currently handled exception * Set expected type of exception in TestInvalidReshape --- src/core/src/model.cpp | 4 ++-- src/core/tests/model.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index 647fd3fa280..05bda13060f 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -877,10 +877,10 @@ void ov::Model::reshape(const std::map, ov::PartialShape>& ssr_manager.run_passes(shared_from_this()); reshape_only(new_param_shapes); - } catch (std::exception& ex) { + } catch (...) { // restore shapes to original ones reshape_only(original_input_shapes); - throw ex; + throw; } } diff --git a/src/core/tests/model.cpp b/src/core/tests/model.cpp index bcfb41f36d1..695dc6df4a4 100644 --- a/src/core/tests/model.cpp +++ b/src/core/tests/model.cpp @@ -741,7 +741,7 @@ TEST(model_reshape, TestInvalidReshape) { f = std::make_shared(ov::OutputVector{reshape}, ov::ParameterVector{input}); } - EXPECT_ANY_THROW(f->reshape({{"tensor", ov::Shape({4})}})); + EXPECT_THROW(f->reshape({{"tensor", ov::Shape({4})}}), ov::Exception); auto param = f->get_parameters().front(); EXPECT_EQ(param->get_output_shape(0), ov::Shape({1, 1000, 4}));