VTK-m  2.1
ErrorCode.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_exec_ErrorCode_h
11 #define vtk_m_exec_ErrorCode_h
12 
13 #include <lcl/ErrorCode.h>
14 
16 namespace vtkm
17 {
18 
28 enum class ErrorCode
29 {
30  // Documentation is below (for better layout in generated documents).
31  Success,
45 
47 };
48 
55 
60 
66 
69 
72 
75 
78 
81 
88 
94 
103 
111 
119 
125 
131 inline const char* ErrorString(vtkm::ErrorCode code) noexcept
132 {
133  switch (code)
134  {
136  return "Success";
138  return "Invalid shape id";
140  return "Invalid number of points";
142  return "Invalid cell metric";
144  return "Wrong shape id for tag type";
146  return "Invalid point id";
148  return "Invalid edge id";
150  return "Invalid face id";
152  return "Solution did not converge";
154  return "Matrix factorization failed";
156  return "Degenerate cell detected";
158  return "Malformed cell detected";
160  return "Operation on empty cell";
162  return "Cell not found";
164  return "Unknown error";
165  }
166 
167  return "Invalid error";
168 }
169 
170 namespace internal
171 {
172 
173 VTKM_EXEC_CONT inline vtkm::ErrorCode LclErrorToVtkmError(lcl::ErrorCode code) noexcept
174 {
175  switch (code)
176  {
177  case lcl::ErrorCode::SUCCESS:
179  case lcl::ErrorCode::INVALID_SHAPE_ID:
181  case lcl::ErrorCode::INVALID_NUMBER_OF_POINTS:
183  case lcl::ErrorCode::WRONG_SHAPE_ID_FOR_TAG_TYPE:
185  case lcl::ErrorCode::INVALID_POINT_ID:
187  case lcl::ErrorCode::SOLUTION_DID_NOT_CONVERGE:
189  case lcl::ErrorCode::MATRIX_LUP_FACTORIZATION_FAILED:
191  case lcl::ErrorCode::DEGENERATE_CELL_DETECTED:
193  }
194 
196 }
197 
198 } // namespace internal
199 
200 } // namespace vtkm
201 
202 #define VTKM_RETURN_ON_ERROR(call) \
203  do \
204  { \
205  auto status = (call); \
206  if (status != ::vtkm::ErrorCode::Success) \
207  { \
208  return status; \
209  } \
210  } while (false)
211 
212 #endif //vtk_m_exec_ErrorCode_h
vtkm::ErrorCode
ErrorCode
Identifies whether an operation was successful or what type of error it had.
Definition: ErrorCode.h:28
vtkm::ErrorCode::WrongShapeIdForTagType
@ WrongShapeIdForTagType
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::ErrorCode::UnknownError
@ UnknownError
vtkm::ErrorCode::DegenerateCellDetected
@ DegenerateCellDetected
An operation detected a degenerate cell.
vtkm::ErrorCode::Success
@ Success
A successful operation.
vtkm::ErrorCode::MatrixFactorizationFailed
@ MatrixFactorizationFailed
A solution was not found for a linear system.
vtkm::ErrorCode::MalformedCellDetected
@ MalformedCellDetected
An operation detected on a malformed cell.
vtkm::ErrorCode::InvalidEdgeId
@ InvalidEdgeId
A bad edge identifier was detected while operating on a cell.
vtkm::ErrorCode::InvalidFaceId
@ InvalidFaceId
A bad face identifier was detected while operating on a cell.
ExportMacros.h
vtkm::ErrorCode::InvalidCellMetric
@ InvalidCellMetric
A cell metric was requested for a cell that does not support that metric.
vtkm::ErrorCode::InvalidPointId
@ InvalidPointId
A bad point identifier was detected while operating on a cell.
vtkm::ErrorCode::CellNotFound
@ CellNotFound
A cell matching some given criteria could not be found.
vtkm::ErrorCode::OperationOnEmptyCell
@ OperationOnEmptyCell
An operation was attempted on a cell with an empty shape.
vtkm::ErrorCode::SolutionDidNotConverge
@ SolutionDidNotConverge
An iterative operation did not find an appropriate solution.
vtkm::ErrorString
const char * ErrorString(vtkm::ErrorCode code) noexcept
Convert a vtkm::ErrorCode into a human-readable string.
Definition: ErrorCode.h:131
vtkm::ErrorCode::InvalidNumberOfPoints
@ InvalidNumberOfPoints
The wrong number of points was provided for a given cell type.
vtkm::ErrorCode::InvalidShapeId
@ InvalidShapeId
A unknown shape identifier was encountered.