Skip to content

Commit 84dfd1c

Browse files
N-Dekkerdzenanz
authored andcommitted
STYLE: Replace "Unknown" default for exception location with {}
It is preferable not duplicate a literal string so many times (following the DRY principle). Moreover, it appears sufficient to use an empty string value (`{}`), to indicate that the location of an exception is unspecified. Note that an unspecified location may be "unknown", but instead, it may also be "irrelevant", or "hidden". So it may depend on the application. Triggered by a discussion with Bradley Lowekamp at #5266 (comment)
1 parent c66eac0 commit 84dfd1c

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

Modules/Core/Common/include/itkExceptionObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ITKCommon_EXPORT ExceptionObject : public std::exception
5959
explicit ExceptionObject(std::string file,
6060
unsigned int lineNumber = 0,
6161
std::string desc = "None",
62-
std::string loc = "Unknown");
62+
std::string loc = {});
6363

6464
/** Copy-constructor. */
6565
ExceptionObject(const ExceptionObject &) noexcept = default;

Modules/IO/ImageBase/include/itkImageFileReaderException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ITKIOImageBase_EXPORT ImageFileReaderException : public ExceptionObject
4040
ImageFileReaderException(std::string file,
4141
unsigned int line,
4242
std::string message = "Error in IO",
43-
std::string loc = "Unknown")
43+
std::string loc = {})
4444
: ExceptionObject(std::move(file), line, std::move(message), std::move(loc))
4545
{}
4646

Modules/IO/ImageBase/include/itkImageFileWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ITKIOImageBase_EXPORT ImageFileWriterException : public ExceptionObject
4343
ImageFileWriterException(std::string file,
4444
unsigned int line,
4545
std::string message = "Error in IO",
46-
std::string loc = "Unknown")
46+
std::string loc = {})
4747
: ExceptionObject(std::move(file), line, std::move(message), std::move(loc))
4848
{}
4949

Modules/IO/MeshBase/include/itkMeshFileReaderException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ITKIOMeshBase_EXPORT MeshFileReaderException : public ExceptionObject
4444
MeshFileReaderException(std::string file,
4545
unsigned int line,
4646
std::string message = "Error in IO",
47-
std::string loc = "Unknown");
47+
std::string loc = {});
4848
};
4949
} // end namespace itk
5050

Modules/IO/MeshBase/include/itkMeshFileWriterException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ITKIOMeshBase_EXPORT MeshFileWriterException : public ExceptionObject
4444
MeshFileWriterException(std::string file,
4545
unsigned int line,
4646
std::string message = "Error in IO",
47-
std::string loc = "Unknown");
47+
std::string loc = {});
4848
};
4949
} // end namespace itk
5050

Modules/Numerics/FEM/include/itkFEMException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ITK_ABI_EXPORT FEMException : public itk::ExceptionObject
4949
* you should use __FILE__ and __LINE__ macros to specify file name
5050
* and line number.
5151
*/
52-
FEMException(std::string file, unsigned int lineNumber, std::string location = "Unknown");
52+
FEMException(std::string file, unsigned int lineNumber, std::string location = {});
5353

5454
/** Virtual destructor needed for subclasses. Has to have empty throw(). */
5555
~FEMException() noexcept override;

0 commit comments

Comments
 (0)