Skip to content

Commit

Permalink
fix(tianmu): feature: The error display is too general, and the cause…
Browse files Browse the repository at this point in the history
… of the error cannot be clearly located #706
  • Loading branch information
CodingSuen authored and mergify[bot] committed Oct 24, 2022
1 parent 2da2e5d commit c96cb89
Show file tree
Hide file tree
Showing 8 changed files with 440 additions and 319 deletions.
18 changes: 9 additions & 9 deletions storage/tianmu/common/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ inline bool IsWarning(ErrorCode tianmu_rc) {
return tianmu_rc == ErrorCode::OUT_OF_RANGE || tianmu_rc == ErrorCode::VALUE_TRUNCATED;
}

class TIANMUError {
class TianmuError {
public:
TIANMUError(ErrorCode tianmu_error_code = ErrorCode::SUCCESS) : ec(tianmu_error_code) {}
TIANMUError(ErrorCode tianmu_error_code, std::string message) : ec(tianmu_error_code), message(message) {}
TIANMUError(const TIANMUError &tianmu_e) : ec(tianmu_e.ec), message(tianmu_e.message) {}
TianmuError(ErrorCode tianmu_error_code = ErrorCode::SUCCESS) : ec(tianmu_error_code) {}
TianmuError(ErrorCode tianmu_error_code, std::string message) : ec(tianmu_error_code), message(message) {}
TianmuError(const TianmuError &tianmu_e) : ec(tianmu_e.ec), message(tianmu_e.message) {}
operator ErrorCode() { return ec; }
ErrorCode GetErrorCode() { return ec; }
bool operator==(ErrorCode tianmu_ec) { return tianmu_ec == ec; }
Expand Down Expand Up @@ -97,7 +97,7 @@ class Exception : public std::runtime_error {
class InternalException : public Exception {
public:
InternalException(std::string const &msg) : Exception(msg) {}
InternalException(TIANMUError tianmu_error) : Exception(tianmu_error.Message()) {}
InternalException(TianmuError tianmu_error) : Exception(tianmu_error.Message()) {}
};

// the system lacks memory or cannot use disk cache
Expand Down Expand Up @@ -157,7 +157,7 @@ class NotImplementedException : public Exception {
class FileException : public Exception {
public:
FileException(std::string const &msg) : Exception(msg) {}
FileException(TIANMUError tianmu_error) : Exception(tianmu_error.Message()) {}
FileException(TianmuError tianmu_error) : Exception(tianmu_error.Message()) {}
};

// wrong format of import file
Expand All @@ -180,22 +180,22 @@ class DataTypeConversionException : public Exception {
DataTypeConversionException(std::string const &msg, int64_t val = NULL_VALUE_64, CT t = CT::UNK)
: Exception(msg), value(val), type(t) {}

DataTypeConversionException(TIANMUError tianmu_error = ErrorCode::DATACONVERSION, int64_t val = NULL_VALUE_64,
DataTypeConversionException(TianmuError tianmu_error = ErrorCode::DATACONVERSION, int64_t val = NULL_VALUE_64,
CT t = CT::UNK)
: Exception(tianmu_error.Message()), value(val), type(t) {}
};

class UnsupportedDataTypeException : public Exception {
public:
UnsupportedDataTypeException(std::string const &msg) : Exception(msg) {}
UnsupportedDataTypeException(TIANMUError tianmu_error = ErrorCode::UNSUPPORTED_DATATYPE)
UnsupportedDataTypeException(TianmuError tianmu_error = ErrorCode::UNSUPPORTED_DATATYPE)
: Exception(tianmu_error.Message()) {}
};

class NetStreamException : public Exception {
public:
NetStreamException(std::string const &msg) : Exception(msg) {}
NetStreamException(TIANMUError tianmu_error) : Exception(tianmu_error.Message()) {}
NetStreamException(TianmuError tianmu_error) : Exception(tianmu_error.Message()) {}
};

class AssertException : public Exception {
Expand Down
Loading

0 comments on commit c96cb89

Please sign in to comment.