LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
expr_errors.cpp
浏览该文件的文档.
1#include "expr.hpp"
2
3#include <string>
4
7namespace LMCAS {
8namespace {
9
10using namespace expr_detail::expr_common;
11
12const char* unit_set_error_name(CasErrc code) noexcept {
13 switch (code) {
15 return "DimensionMismatch";
16 }
18 return "UnitInvalid";
19 }
21 return "UnitStripTypeMismatch";
22 }
24 return "SetElementTypeMismatch";
25 }
27 return "SetOperandTypeMismatch";
28 }
30 return "SetElementNotHashable";
31 }
32 default: {
33 return "InternalInvariant";
34 }
35 }
36}
37
38const char* equivalence_error_name(const CasError& error) noexcept {
39 if (error.operation == kEquivalentOperation &&
40 error.code == CasErrc::ResourceLimit) {
41 return "EqvBudgetExceeded";
42 }
43 if (error.operation == kEquivalentProfileOperation &&
44 error.code == CasErrc::UnsupportedExpression) {
45 return "EqvRuleDisabled";
46 }
47 return error_name(error.code);
48}
49
50}
51
52const char* error_name(CasErrc code) noexcept {
53 switch (code) {
55 return "InvalidArgument";
56 }
58 return "ParseError";
59 }
61 return "UnboundSymbol";
62 }
64 return "DomainError";
65 }
67 return "UnsupportedExpression";
68 }
70 return "Inconclusive";
71 }
73 return "ResourceLimit";
74 }
75 case CasErrc::Cancelled: {
76 return "Cancelled";
77 }
79 return "NumericFailure";
80 }
82 return "InternalInvariant";
83 }
84 default: {
85 return unit_set_error_name(code);
86 }
87 }
88}
89
90const char* error_name(const CasError& error) noexcept {
91 if (error.operation == kSymOperation &&
92 error.code == CasErrc::InvalidArgument &&
93 error.message.find("imaginary unit") != std::string::npos) {
94 return "ImaginaryUnitReserved";
95 }
96 if (error.operation == kEvalComplexOperation &&
97 error.code == CasErrc::UnboundSymbol) {
98 return "ComplexEvalUnboundSymbol";
99 }
100 if (error.operation == kComplexOperation &&
101 error.code == CasErrc::InvalidArgument) {
102 return "ComplexTypeMismatch";
103 }
104 if (error.operation == kExprSetOperation &&
105 error.code == CasErrc::InvalidArgument) {
106 return "SetElementTypeMismatch";
107 }
108 if (error.operation == kSolveExprSetOperation &&
109 error.code == CasErrc::Inconclusive) {
110 return "SetResultInconclusive";
111 }
112 return equivalence_error_name(error);
113}
114
115}
const char * unit_set_error_name(CasErrc code) noexcept
const char * equivalence_error_name(const CasError &error) noexcept
constexpr const char * kSymOperation
constexpr const char * kComplexOperation
constexpr const char * kEquivalentProfileOperation
constexpr const char * kEvalComplexOperation
constexpr const char * kSolveExprSetOperation
const char * error_name(CasErrc code) noexcept
constexpr const char * kExprSetOperation
constexpr const char * kEquivalentOperation