1 //============================================================================ 2 // Copyright (c) Kitware, Inc. 3 // All rights reserved. 4 // See LICENSE.md 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 lcl_ErrorCode_h 11 #define lcl_ErrorCode_h 12 13 #include <lcl/internal/Config.h> 14 15 #include <cstdint> 16 17 namespace lcl 18 { 19 20 enum class ErrorCode : std::int32_t 21 { 22 SUCCESS = 0, 23 INVALID_SHAPE_ID, 24 INVALID_NUMBER_OF_POINTS, 25 WRONG_SHAPE_ID_FOR_TAG_TYPE, 26 INVALID_POINT_ID, 27 SOLUTION_DID_NOT_CONVERGE, 28 MATRIX_LUP_FACTORIZATION_FAILED, 29 DEGENERATE_CELL_DETECTED 30 }; 31 32 LCL_EXEC errorString(ErrorCode code)33inline const char* errorString(ErrorCode code) noexcept 34 { 35 switch (code) 36 { 37 case ErrorCode::SUCCESS: 38 return "Success"; 39 case ErrorCode::INVALID_SHAPE_ID: 40 return "Invalid shape id"; 41 case ErrorCode::INVALID_NUMBER_OF_POINTS: 42 return "Invalid number of points"; 43 case ErrorCode::WRONG_SHAPE_ID_FOR_TAG_TYPE: 44 return "Wrong shape id for tag type"; 45 case ErrorCode::INVALID_POINT_ID: 46 return "Invalid point id"; 47 case ErrorCode::SOLUTION_DID_NOT_CONVERGE: 48 return "Solution did not converge"; 49 case ErrorCode::MATRIX_LUP_FACTORIZATION_FAILED: 50 return "LUP factorization failed"; 51 case ErrorCode::DEGENERATE_CELL_DETECTED: 52 return "Degenerate cell detected"; 53 } 54 55 return "Invalid error"; 56 } 57 58 } // lcl 59 60 #define LCL_RETURN_ON_ERROR(call) \ 61 { \ 62 auto status = call; \ 63 if (status != lcl::ErrorCode::SUCCESS) \ 64 { \ 65 return status; \ 66 } \ 67 } 68 69 #endif // lcl_ErrorCode_h 70