Skip to content

Commit

Permalink
STYLE: Catch exceptions by _const_ reference
Browse files Browse the repository at this point in the history
Replaced `catch \((\S+) &` & with `catch \(const $1 &`, using Notepad++ v8.3.3,
Find in Files, Search Mode: Regular expression.

Follow-up to ITK pull request InsightSoftwareConsortium/ITK#3419
commit InsightSoftwareConsortium/ITK@f222a5e
(merged on May 11, 2022)
  • Loading branch information
N-Dekker committed May 16, 2022
1 parent e49dee5 commit 851d543
Show file tree
Hide file tree
Showing 134 changed files with 157 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ main(int argc, char * argv[])
{
filter->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ main(int argc, char * argv[])
{
filter->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ main(int argc, char * argv[])
reader->Update();
filter->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ main(int argc, char * argv[])
{
filter->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ main(int argc, char * argv[])
{
visualizer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ main(int argc, char * argv[])
{
visualizer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ main(int argc, char * argv[])
{
visualizer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ main(int argc, char * argv[])
{
visualizer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ main(int argc, char * argv[])
{
visualizer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/ImageRegionOverlap/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(image, out_file_name);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/ImportPixelBufferIntoAnImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ main(int argc, char * argv[])
{
writer->Update();
}
catch (itk::ExceptionObject & exp)
catch (const itk::ExceptionObject & exp)
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << exp << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ main(int argc, char * argv[])
std::cout << largestRegion << std::endl;
;
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand All @@ -77,7 +77,7 @@ main(int argc, char * argv[])
reader->SetFileNames(fileNames);
reader->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
// Print out the error that occurs
std::cout << "Error: " << error << std::endl;
Expand All @@ -97,7 +97,7 @@ main(int argc, char * argv[])
std::cout << largestRegion << std::endl;
;
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/ReadAPointSet/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ main(int argc, char * argv[])
{
polyDataReader->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/ReadWriteVectorImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(input, argv[2]);
}
catch (itk::ExceptionObject & err)
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/SetPixelValueInOneImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(image, argv[1]);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/StreamAPipeline/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ main(int argc, char * argv[])
{
streamingFilter->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/TryCatchException/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ main(int, char *[])
{
reader->Update();
}
catch (itk::ExceptionObject & err)
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Common/UseParallelizeImageRegion/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ main(int argc, char * argv[])
OutputImageType::Pointer outImage = segmentationAndCustomColorization(input);
itk::WriteImage(outImage, argv[2], true); // compression
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/ImageFunction/ResampleSegmentedImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(resizeFilter->GetOutput(), outputImageFileLabelImageInterpolator, true); // compress
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand All @@ -115,7 +115,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(resizeFilter->GetOutput(), outputImageFileNearestNeighborInterpolator, true); // compress
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Mesh/ConvertTriangleMeshToBinaryImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ main(int argc, char * argv[])
{
filter->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand All @@ -82,7 +82,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(filter->GetOutput(), outputImageName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Mesh/ExtractIsoSurface/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ main(int argc, char * argv[])
{
writer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Mesh/TranslateOneMesh/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ main(int argc, char * argv[])
{
writer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ main(int argc, char * argv[])
{
writer->Update();
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/QuadEdgeMesh/CutMesh/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ main(int argc, char * argv[])
{
writer->Update();
}
catch (itk::ExceptionObject & e)
catch (const itk::ExceptionObject & e)
{
std::cerr << "Error: " << e << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ main(int argc, char * argv[])
{
reader->Update();
}
catch (itk::ExceptionObject & e)
catch (const itk::ExceptionObject & e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ main(int argc, char * argv[])
{
reader->Update();
}
catch (itk::ExceptionObject & e)
catch (const itk::ExceptionObject & e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/QuadEdgeMesh/PrintVertexNeighbors/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ main(int argc, char * argv[])
{
reader->Update();
}
catch (itk::ExceptionObject & e)
catch (const itk::ExceptionObject & e)
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ main(int argc, char * argv[])
imageFilter->Update();
itk::WriteImage(imageFilter->GetOutput(), argv[1], true); // compress
}
catch (itk::ExceptionObject & excp)
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/SpatialObjects/Ellipse/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ main(int argc, char * argv[])
imageFilter->Update();
itk::WriteImage(imageFilter->GetOutput(), argv[1]);
}
catch (itk::ExceptionObject & excp)
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/TestKernel/GenerateRandomImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(randomImageSource->GetOutput(), outputFileName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(resample->GetOutput(), outputFileName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ main(int, char *[])
{
registration->Update();
}
catch (itk::ExceptionObject & err)
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ main(int itkNotUsed(argc), char * itkNotUsed(argv)[])
std::cout << "Optimizer stop condition = " << registration->GetOptimizer()->GetStopConditionDescription()
<< std::endl;
}
catch (itk::ExceptionObject & err)
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
Expand Down Expand Up @@ -186,7 +186,7 @@ main(int itkNotUsed(argc), char * itkNotUsed(argv)[])
{
itk::WriteImage(caster->GetOutput(), "output.png");
}
catch (itk::ExceptionObject & err)
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Transform/MutualInformationAffine/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ main(int argc, char * argv[])
std::cout << "Optimizer stop condition: " << registration->GetOptimizer()->GetStopConditionDescription()
<< std::endl;
}
catch (itk::ExceptionObject & err)
catch (const itk::ExceptionObject & err)
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Transform/TranslateImage/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(resampleFilter->GetOutput(), outputFileName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(rescaler->GetOutput(), outputFileName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(rescaler->GetOutput(), outputFileName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(rescaler->GetOutput(), outputFileName);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ main(int argc, char * argv[])
{
itk::WriteImage(filter->GetOutput(), argv[2]);
}
catch (itk::ExceptionObject & error)
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
Expand Down
Loading

0 comments on commit 851d543

Please sign in to comment.