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}));