From: Wolfgang Bangerth Date: Sun, 16 Jul 2017 16:39:05 +0000 (-0600) Subject: Replace message-less exceptions with ones that say what's happening. X-Git-Tag: v9.0.0-rc1~1414^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4617%2Fhead;p=dealii.git Replace message-less exceptions with ones that say what's happening. --- diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index b127266e5a..77de465c2b 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -2047,9 +2047,13 @@ DoFAccessor::get_dof_indices (std::vector &dof_indices, const unsigned int fe_index) const { - Assert (this->dof_handler != nullptr, ExcNotInitialized()); + Assert (this->dof_handler != nullptr, + ExcMessage("This accessor object has not been associated " + "with any DoFHandler object.")); Assert (static_cast(this->level()) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); + ExcMessage ("The DoFHandler to which this accessor points has not " + "been initialized, i.e., it doesn't appear that DoF indices " + "have been distributed on it.")); switch (structdim) { diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 515b9f613f..8cce7cbdfb 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -1227,7 +1227,9 @@ inline const Triangulation & DoFHandler::get_triangulation () const { - Assert(tria != nullptr, ExcNotInitialized()); + Assert(tria != nullptr, + ExcMessage("This DoFHandler object has not been associated " + "with a triangulation.")); return *tria; } diff --git a/include/deal.II/dofs/dof_renumbering.h b/include/deal.II/dofs/dof_renumbering.h index 9c61467a33..43212cb374 100644 --- a/include/deal.II/dofs/dof_renumbering.h +++ b/include/deal.II/dofs/dof_renumbering.h @@ -1072,18 +1072,32 @@ namespace DoFRenumbering * @} */ + + + /** + * Exception + * + * @ingroup Exceptions + */ + DeclExceptionMsg (ExcDoFHandlerNotInitialized, + "The DoFHandler on which this function should work has not " + "been initialized, i.e., it doesn't appear that DoF indices " + "have been distributed on it."); + /** * Exception * * @ingroup Exceptions */ DeclException0 (ExcRenumberingIncomplete); + /** * Exception * * @ingroup Exceptions */ DeclException0 (ExcInvalidComponentOrder); + /** * The function is only implemented for Discontinuous Galerkin Finite * elements. diff --git a/include/deal.II/hp/dof_handler.h b/include/deal.II/hp/dof_handler.h index 81c0e3f40f..f315534172 100644 --- a/include/deal.II/hp/dof_handler.h +++ b/include/deal.II/hp/dof_handler.h @@ -1054,6 +1054,9 @@ namespace hp const Triangulation & DoFHandler::get_triangulation () const { + Assert(tria != nullptr, + ExcMessage("This DoFHandler object has not been associated " + "with a triangulation.")); return *tria; } diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index 652efdf5e4..81200c8fa5 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -474,7 +474,7 @@ namespace DoFRenumbering const std::vector &starting_indices) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); // make the connection graph DynamicSparsityPattern dsp (dof_handler.n_dofs(level), @@ -541,7 +541,7 @@ namespace DoFRenumbering const std::vector &component_order_arg) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering (dof_handler.n_dofs(level), numbers::invalid_dof_index); @@ -874,7 +874,7 @@ namespace DoFRenumbering block_wise (DoFHandler &dof_handler, const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering (dof_handler.n_dofs(level), numbers::invalid_dof_index); @@ -1238,7 +1238,7 @@ namespace DoFRenumbering const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering(dof_handler.n_dofs(level), numbers::invalid_dof_index); @@ -1295,7 +1295,7 @@ namespace DoFRenumbering const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); const unsigned int n_dofs = dof_handler.n_dofs(level); Assert (selected_dofs.size() == n_dofs, @@ -1419,7 +1419,7 @@ namespace DoFRenumbering const typename std::vector &cells) { Assert(dof.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering(dof.n_dofs(level)); std::vector reverse(dof.n_dofs(level));