Fix catching by value
Pointed out by LGTM. Change-Id: I223655c728305f6f45b3738553da5b7d7a69e8c8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2134 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Jérôme Duval
parent
654135466f
commit
992ae400ec
@@ -518,7 +518,7 @@ GPJob::Write(const char* data, size_t size)
|
||||
{
|
||||
try {
|
||||
fOutputStream->Write(data, size);
|
||||
} catch (TransportException e) {
|
||||
} catch (TransportException& e) {
|
||||
fStatus = B_IO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1124,7 +1124,7 @@ CalcView::_EvaluateThread(void* data)
|
||||
BString expression(calcView->fExpressionTextView->Text());
|
||||
try {
|
||||
result = parser.Evaluate(expression.String());
|
||||
} catch (ParseException e) {
|
||||
} catch (ParseException& e) {
|
||||
result << e.message.String() << " at " << (e.position + 1);
|
||||
status = B_ERROR;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ main(int argc, char* argv[])
|
||||
ExpressionParser parser;
|
||||
BString result = parser.Evaluate(expression.String());
|
||||
printf("%s\n", result.String());
|
||||
} catch (ParseException e) {
|
||||
} catch (ParseException& e) {
|
||||
printf("%s at %" B_PRId32 "\n", e.message.String(), e.position + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
const char* packageNameString = packageName.String();
|
||||
try {
|
||||
fPackageManager->Install(&packageNameString, 1);
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
BString errorString;
|
||||
errorString.SetToFormat(
|
||||
"Fatal error occurred while installing package %s: "
|
||||
@@ -162,18 +162,18 @@ public:
|
||||
_SetDownloadedPackagesState(NONE);
|
||||
ref->SetState(state);
|
||||
return ex.Error();
|
||||
} catch (BAbortedByUserException ex) {
|
||||
} catch (BAbortedByUserException& ex) {
|
||||
fprintf(stderr, "Installation of package "
|
||||
"%s aborted by user: %s\n", packageNameString,
|
||||
ex.Message().String());
|
||||
_SetDownloadedPackagesState(NONE);
|
||||
ref->SetState(state);
|
||||
return B_OK;
|
||||
} catch (BNothingToDoException ex) {
|
||||
} catch (BNothingToDoException& ex) {
|
||||
fprintf(stderr, "Nothing to do while installing package "
|
||||
"%s: %s\n", packageNameString, ex.Message().String());
|
||||
return B_OK;
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
fprintf(stderr, "Exception occurred while installing package "
|
||||
"%s: %s\n", packageNameString, ex.Message().String());
|
||||
_SetDownloadedPackagesState(NONE);
|
||||
@@ -273,7 +273,7 @@ public:
|
||||
const char* packageName = ref->Name().String();
|
||||
try {
|
||||
fPackageManager->Uninstall(&packageName, 1);
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
BString errorString;
|
||||
errorString.SetToFormat(
|
||||
"Fatal error occurred while uninstalling package %s: "
|
||||
@@ -286,11 +286,11 @@ public:
|
||||
alert->Go();
|
||||
ref->SetState(state);
|
||||
return ex.Error();
|
||||
} catch (BAbortedByUserException ex) {
|
||||
} catch (BAbortedByUserException& ex) {
|
||||
return B_OK;
|
||||
} catch (BNothingToDoException ex) {
|
||||
} catch (BNothingToDoException& ex) {
|
||||
return B_OK;
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
fprintf(stderr, "Exception occurred while uninstalling package "
|
||||
"%s: %s\n", packageName, ex.Message().String());
|
||||
ref->SetState(state);
|
||||
@@ -634,11 +634,11 @@ PackageManager::RefreshRepository(const BRepositoryConfig& repoConfig)
|
||||
status_t result;
|
||||
try {
|
||||
result = BPackageManager::RefreshRepository(repoConfig);
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
fprintf(stderr, "Fatal error occurred while refreshing repository: "
|
||||
"%s (%s)\n", ex.Message().String(), ex.Details().String());
|
||||
result = ex.Error();
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
fprintf(stderr, "Exception occurred while refreshing "
|
||||
"repository: %s\n", ex.Message().String());
|
||||
result = B_ERROR;
|
||||
@@ -656,12 +656,12 @@ PackageManager::DownloadPackage(const BString& fileURL,
|
||||
try {
|
||||
result = BPackageManager::DownloadPackage(fileURL, targetEntry,
|
||||
checksum);
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
fprintf(stderr, "Fatal error occurred while downloading package: "
|
||||
"%s: %s (%s)\n", fileURL.String(), ex.Message().String(),
|
||||
ex.Details().String());
|
||||
result = ex.Error();
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
fprintf(stderr, "Exception occurred while downloading package "
|
||||
"%s: %s\n", fileURL.String(), ex.Message().String());
|
||||
result = B_ERROR;
|
||||
|
||||
@@ -130,7 +130,7 @@ LocalPkgDataLoadProcess::RunInternal()
|
||||
try {
|
||||
manager.Init(PackageManager::B_ADD_INSTALLED_REPOSITORIES
|
||||
| PackageManager::B_ADD_REMOTE_REPOSITORIES);
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
BString message(B_TRANSLATE("An error occurred while "
|
||||
"initializing the package manager: %message%"));
|
||||
message.ReplaceFirst("%message%", ex.Message());
|
||||
@@ -362,12 +362,12 @@ LocalPkgDataLoadProcess::RunInternal()
|
||||
it->second->SetSystemDependency(true);
|
||||
}
|
||||
}
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
printf("Fatal exception occurred while resolving system dependencies: "
|
||||
"%s, details: %s\n", strerror(ex.Error()), ex.Details().String());
|
||||
} catch (BNothingToDoException) {
|
||||
} catch (BNothingToDoException&) {
|
||||
// do nothing
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
printf("Exception occurred while resolving system dependencies: %s\n",
|
||||
ex.Message().String());
|
||||
} catch (...) {
|
||||
@@ -390,4 +390,4 @@ LocalPkgDataLoadProcess::_NotifyError(const BString& messageText) const
|
||||
AppUtils::NotifySimpleError(
|
||||
B_TRANSLATE("Local repository load error"),
|
||||
messageText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ LocalRepositoryUpdateProcess::_RunForRepositoryName(const BString& repoName,
|
||||
BRefreshRepositoryRequest refreshRequest(context, repoConfig);
|
||||
result = refreshRequest.Process();
|
||||
result = B_OK;
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
_NotifyError(ex.Message(), ex.Details());
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
_NotifyError(ex.Message());
|
||||
}
|
||||
}
|
||||
@@ -153,4 +153,4 @@ LocalRepositoryUpdateProcess::_NotifyError(const BString& error,
|
||||
AppUtils::NotifySimpleError(
|
||||
B_TRANSLATE("Repository update error"),
|
||||
alertText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,21 +51,21 @@ CheckAction::Perform()
|
||||
int packageCount = 0;
|
||||
const char* const packages = "";
|
||||
fCheckManager->Update(&packages, packageCount);
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
fprintf(stderr, B_TRANSLATE(
|
||||
"Fatal error while checking for updates: %s\n"),
|
||||
ex.Message().String());
|
||||
be_app->PostMessage(kMsgFinalQuit);
|
||||
return ex.Error();
|
||||
} catch (BAbortedByUserException ex) {
|
||||
} catch (BAbortedByUserException& ex) {
|
||||
be_app->PostMessage(kMsgFinalQuit);
|
||||
return B_OK;
|
||||
} catch (BNothingToDoException ex) {
|
||||
} catch (BNothingToDoException& ex) {
|
||||
puts(B_TRANSLATE("There were no updates found."));
|
||||
fCheckManager->NoUpdatesNotification();
|
||||
be_app->PostMessage(kMsgFinalQuit);
|
||||
return B_OK;
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
fprintf(stderr, B_TRANSLATE(
|
||||
"Exception occurred while checking for updates: %s\n"),
|
||||
ex.Message().String());
|
||||
|
||||
@@ -73,25 +73,25 @@ UpdateAction::Perform(update_type action_request)
|
||||
throw BException(B_TRANSLATE(
|
||||
"Invalid update type, cannot continue with updates"));
|
||||
|
||||
} catch (BFatalErrorException ex) {
|
||||
} catch (BFatalErrorException& ex) {
|
||||
fUpdateManager->FinalUpdate(B_TRANSLATE("Updates did not complete"),
|
||||
ex.Message());
|
||||
return ex.Error();
|
||||
} catch (BAbortedByUserException ex) {
|
||||
} catch (BAbortedByUserException& ex) {
|
||||
if (fVerbose)
|
||||
fprintf(stderr, "Updates aborted by user: %s\n",
|
||||
ex.Message().String());
|
||||
// No need for a final message since user initiated cancel request
|
||||
be_app->PostMessage(kMsgFinalQuit);
|
||||
return B_OK;
|
||||
} catch (BNothingToDoException ex) {
|
||||
} catch (BNothingToDoException& ex) {
|
||||
if (fVerbose)
|
||||
fprintf(stderr, "Nothing to do while updating packages : %s\n",
|
||||
ex.Message().String());
|
||||
fUpdateManager->FinalUpdate(B_TRANSLATE("No updates available"),
|
||||
B_TRANSLATE("There were no updates found."));
|
||||
return B_OK;
|
||||
} catch (BException ex) {
|
||||
} catch (BException& ex) {
|
||||
if (fVerbose)
|
||||
fprintf(stderr, B_TRANSLATE(
|
||||
"Exception occurred while updating packages : %s\n"),
|
||||
|
||||
@@ -278,7 +278,7 @@ SymbolLookup::Init()
|
||||
TRACE(("SymbolLookup::Init(): translated debug area is at: %p, "
|
||||
"loaded_images: %p\n", fDebugArea, fDebugArea->loaded_images));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception& exception) {
|
||||
// we can live without the debug area
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ debug_create_symbol_lookup_context(team_id team, image_id image,
|
||||
status_t error = lookup->Init();
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
} catch (BPrivate::Debug::Exception exception) {
|
||||
} catch (BPrivate::Debug::Exception& exception) {
|
||||
return exception.Error();
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext,
|
||||
exactMatch);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
} catch (BPrivate::Debug::Exception exception) {
|
||||
} catch (BPrivate::Debug::Exception& exception) {
|
||||
return exception.Error();
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ debug_create_image_symbol_iterator(debug_symbol_lookup_context* lookupContext,
|
||||
status_t error;
|
||||
try {
|
||||
error = lookup->InitSymbolIterator(imageID, *iterator);
|
||||
} catch (BPrivate::Debug::Exception exception) {
|
||||
} catch (BPrivate::Debug::Exception& exception) {
|
||||
error = exception.Error();
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ debug_create_image_symbol_iterator(debug_symbol_lookup_context* lookupContext,
|
||||
try {
|
||||
error = lookup->InitSymbolIteratorByAddress(
|
||||
(addr_t)imageInfo.text, *iterator);
|
||||
} catch (BPrivate::Debug::Exception exception) {
|
||||
} catch (BPrivate::Debug::Exception& exception) {
|
||||
error = exception.Error();
|
||||
}
|
||||
}
|
||||
@@ -565,7 +565,7 @@ debug_next_image_symbol(debug_symbol_iterator* iterator, char* nameBuffer,
|
||||
_symbolType);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
} catch (BPrivate::Debug::Exception exception) {
|
||||
} catch (BPrivate::Debug::Exception& exception) {
|
||||
return exception.Error();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ CLanguageFamily::EvaluateExpression(const BString& expression,
|
||||
try {
|
||||
_output = evaluator.Evaluate(expression, manager, info);
|
||||
return B_OK;
|
||||
} catch (ParseException ex) {
|
||||
} catch (ParseException& ex) {
|
||||
BString error;
|
||||
error.SetToFormat("Parse error at position %" B_PRId32 ": %s",
|
||||
ex.position, ex.message.String());
|
||||
@@ -64,7 +64,7 @@ CLanguageFamily::EvaluateExpression(const BString& expression,
|
||||
return B_NO_MEMORY;
|
||||
_output->SetToPrimitive(value);
|
||||
return B_BAD_DATA;
|
||||
} catch (ValueNeededException ex) {
|
||||
} catch (ValueNeededException& ex) {
|
||||
_neededNode = ex.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ ResourceFile::SetTo(BFile* file, bool clobber)
|
||||
if (error == B_OK) {
|
||||
try {
|
||||
_InitFile(*file, clobber);
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception& exception) {
|
||||
Unset();
|
||||
if (exception.Error() != B_OK)
|
||||
error = exception.Error();
|
||||
@@ -295,7 +295,7 @@ ResourceFile::InitContainer(ResourcesContainer& container)
|
||||
_ReadIndex(parseInfo);
|
||||
_ReadInfoTable(parseInfo);
|
||||
container.SetModified(false);
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception& exception) {
|
||||
if (exception.Error() != B_OK)
|
||||
error = exception.Error();
|
||||
else
|
||||
@@ -1272,7 +1272,7 @@ ResourceFile::_WriteResources(ResourcesContainer& container)
|
||||
tableEnd->rite_terminator = 0;
|
||||
write_exactly(fFile, infoTableOffset, buffer, infoTableSize,
|
||||
"Failed to write info table.");
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception& exception) {
|
||||
if (exception.Error() != B_OK)
|
||||
error = exception.Error();
|
||||
else
|
||||
@@ -1302,7 +1302,7 @@ ResourceFile::_MakeEmptyResourceFile()
|
||||
fFileType = FILE_TYPE_X86_RESOURCE;
|
||||
fFile.SetTo(file, kX86ResourcesOffset);
|
||||
fEmptyResources = true;
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception& exception) {
|
||||
if (exception.Error() != B_OK)
|
||||
error = exception.Error();
|
||||
else
|
||||
|
||||
@@ -1788,7 +1788,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
|
||||
} catch (status_t error) {
|
||||
// no alert, was already taken care of before
|
||||
return error;
|
||||
} catch (MoveError error) {
|
||||
} catch (MoveError& error) {
|
||||
BString errorString(B_TRANSLATE("Error moving \"%name\""));
|
||||
errorString.ReplaceFirst("%name", ref.name);
|
||||
BAlert* alert = new BAlert("", errorString.String(), B_TRANSLATE("OK"),
|
||||
@@ -1796,7 +1796,7 @@ MoveItem(BEntry* entry, BDirectory* destDir, BPoint* loc, uint32 moveMode,
|
||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
alert->Go();
|
||||
return error.fError;
|
||||
} catch (FailWithAlert error) {
|
||||
} catch (FailWithAlert& error) {
|
||||
BString buffer(error.fString);
|
||||
if (error.fName != NULL)
|
||||
buffer.ReplaceFirst("%name", error.fName);
|
||||
|
||||
@@ -90,7 +90,7 @@ main(int argc, const char* const* argv)
|
||||
for (int i = 0; i < packageCount; i++)
|
||||
installedRepositoryBuilder.AddPackage(packages[i]);
|
||||
installedRepositoryBuilder.AddToSolver(solver, true);
|
||||
} catch (BFatalErrorException e) {
|
||||
} catch (BFatalErrorException& e) {
|
||||
DIE(e.Error(), "%s %s", e.Message().String(), e.Details().String());
|
||||
}
|
||||
|
||||
|
||||
@@ -696,7 +696,7 @@ main(int argc, const char* const* argv)
|
||||
min((size_t)SYSTEM_REVISION_LENGTH, strlen(revisionString) + 1),
|
||||
"Failed to write revision.");
|
||||
|
||||
} catch (Exception exception) {
|
||||
} catch (Exception& exception) {
|
||||
if (exception.Description() == "") {
|
||||
fprintf(stderr, "%s\n", strerror(exception.Error()));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user