negotiateFunction where appropriate.
Replacing the old ECError with a custom type allows us to attach the name of
the function that could not be negotiated, enabling better diagnostics for
negotiation failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292055
91177308-0d34-0410-b5e6-
96231b3b80d8
Error orcError(OrcErrorCode ErrCode);
+class RPCFunctionNotSupported : public ErrorInfo<RPCFunctionNotSupported> {
+public:
+ static char ID;
+
+ RPCFunctionNotSupported(std::string RPCFunctionSignature);
+ std::error_code convertToErrorCode() const override;
+ void log(raw_ostream &OS) const override;
+ const std::string &getFunctionSignature() const;
+private:
+ std::string RPCFunctionSignature;
+};
+
} // End namespace orc.
} // End namespace llvm.
return Error::success();
// If it's invalid and we can't re-attempt negotiation, throw an error.
if (!Retry)
- return orcError(OrcErrorCode::UnknownRPCFunction);
+ return make_error<RPCFunctionNotSupported>(Func::getPrototype());
}
// We don't have a function id for Func yet, call the remote to try to
return Error::success();
// If it's invalid and we can't re-attempt negotiation, throw an error.
if (!Retry)
- return orcError(OrcErrorCode::UnknownRPCFunction);
+ return make_error<RPCFunctionNotSupported>(Func::getPrototype());
}
// We don't have a function id for Func yet, call the remote to try to
namespace llvm {
namespace orc {
+char RPCFunctionNotSupported::ID = 0;
+
Error orcError(OrcErrorCode ErrCode) {
typedef std::underlying_type<OrcErrorCode>::type UT;
return errorCodeToError(
std::error_code(static_cast<UT>(ErrCode), *OrcErrCat));
}
+
+RPCFunctionNotSupported::RPCFunctionNotSupported(std::string RPCFunctionSignature)
+ : RPCFunctionSignature(std::move(RPCFunctionSignature)) {}
+
+std::error_code RPCFunctionNotSupported::convertToErrorCode() const {
+ typedef std::underlying_type<OrcErrorCode>::type UT;
+ return std::error_code(static_cast<UT>(OrcErrorCode::UnknownRPCFunction),
+ *OrcErrCat);
+}
+
+void RPCFunctionNotSupported::log(raw_ostream &OS) const {
+ OS << "Could not negotiate RPC function '" << RPCFunctionSignature << "'";
+}
+
+const std::string &RPCFunctionNotSupported::getFunctionSignature() const {
+ return RPCFunctionSignature;
+}
+
}
}