From 3ee69e8eb082188521102c6bdc4b4be72a4d2e29 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de> Date: Mon, 26 Jul 2021 19:04:49 +0200 Subject: [PATCH] no 'else' after 'return'; ASSERT, not throw, in impossible cases --- GUI/Models/GUIDomainSampleVisitor.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/GUI/Models/GUIDomainSampleVisitor.cpp b/GUI/Models/GUIDomainSampleVisitor.cpp index df0daf1df7e..e290f8dc6c5 100644 --- a/GUI/Models/GUIDomainSampleVisitor.cpp +++ b/GUI/Models/GUIDomainSampleVisitor.cpp @@ -570,10 +570,8 @@ ExternalProperty GUIDomainSampleVisitor::createMaterialFromDomain(const Material } else if (material->typeID() == MATERIAL_TYPES::MaterialBySLD) { mat_item = m_materialModel->addSLDMaterial(materialName, material_data.real(), material_data.imag()); - } else { - throw Error("GUI::Model::ObjectBuilder::createMaterialFromDomain() -> Error. " - "Unsupported material"); - } + } else + ASSERT(0); mat_item->setMagnetization(material->magnetization()); return GUI::Model::MaterialItemUtils::materialProperty(*mat_item); @@ -598,16 +596,13 @@ ParticleItem* GUIDomainSampleVisitor::CreateIParticle(SessionItem* parent, dynamic_cast<const ParticleCoreShell*>(m_itemToSample[parent]); ASSERT(coreshell); ParticleCoreShellItem* parentCoreShell = polymorphic_cast<ParticleCoreShellItem*>(parent); - if (particle == coreshell->coreParticle()) { + if (particle == coreshell->coreParticle()) return parentCoreShell->createCore(); - } else if (particle == coreshell->shellParticle()) { + if (particle == coreshell->shellParticle()) return parentCoreShell->createShell(); - } else { - throw Error("GUI::Model::ObjectBuilder::InsertIParticle:" - "Particle not found in parent ParticleCoreShell"); - } - } else - return m_sampleModel->insertItem<ParticleItem>(parent, -1); + ASSERT(0); + } + return m_sampleModel->insertItem<ParticleItem>(parent, -1); } // Used only in this file -- GitLab