Add a createError variant without error code (NFC) (#93209)
For the significant amount of call sites that want to create an incontrovertible error, such a wrapper function creates a significant readability improvement and lowers the cost of entry to add error handling in more places.
This commit is contained in:
@@ -2494,8 +2494,7 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
|
||||
|
||||
auto ExtendSysPath = [&](std::string directory) -> llvm::Error {
|
||||
if (directory.empty()) {
|
||||
return llvm::make_error<llvm::StringError>(
|
||||
"invalid directory name", llvm::inconvertibleErrorCode());
|
||||
return llvm::createStringError("invalid directory name");
|
||||
}
|
||||
|
||||
replace_all(directory, "\\", "\\\\");
|
||||
@@ -2508,10 +2507,8 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
|
||||
directory.c_str(), directory.c_str());
|
||||
bool syspath_retval =
|
||||
ExecuteMultipleLines(command_stream.GetData(), exc_options).Success();
|
||||
if (!syspath_retval) {
|
||||
return llvm::make_error<llvm::StringError>(
|
||||
"Python sys.path handling failed", llvm::inconvertibleErrorCode());
|
||||
}
|
||||
if (!syspath_retval)
|
||||
return llvm::createStringError("Python sys.path handling failed");
|
||||
|
||||
return llvm::Error::success();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user