File size: 21,278 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | /*
* Original work Copyright 2009 - 2010 Kevin Ackley (kackley@gwi.net)
* Modified work Copyright 2018 - 2020 Andy Maloney <asmaloney@gmail.com>
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#pragma once
/// @file E57Exception.h Exception handling for E57 API.
#include <exception>
#include <iostream>
#include <string>
#include "E57Export.h"
#ifndef E57_ENABLE_DIAGNOSTIC_OUTPUT
// Used to mark unused parameters to indicate intent and suppress warnings.
#define E57_UNUSED( expr ) (void)( expr )
#endif
// C++14 does not support the [[deprecated]] attribute on enumerators.
// Turn on enumerator deprecation notices if we are compiling with C++17 or later.
#if ( ( defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L )
#define E57_DEPRECATED_ENUM( str ) [[deprecated( str )]]
#else
#define E57_DEPRECATED_ENUM( str )
#endif
namespace e57
{
/// @brief Numeric error identifiers used in E57Exception
enum ErrorCode
{
// NOTE: When changing error strings here, remember to update the error strings in
// E57Exception.cpp
Success = 0, ///< operation was successful
ErrorBadCVHeader = 1, ///< a CompressedVector binary header was bad
ErrorBadCVPacket = 2, ///< a CompressedVector binary packet was bad
ErrorChildIndexOutOfBounds = 3, ///< a numerical index identifying a child was out of bounds
ErrorSetTwice = 4, ///< attempted to set an existing child element to a new value
/// @brief attempted to add an element that would have made the children of a homogeneous
/// ::TypeVector have different types
ErrorHomogeneousViolation = 5,
/// a value could not be represented in the requested type
ErrorValueNotRepresentable = 6,
/// after scaling the result could not be represented in the requested type
ErrorScaledValueNotRepresentable = 7,
/// a 64 bit IEEE float was too large to store in a 32 bit IEEE float
ErrorReal64TooLarge = 8,
/// expecting numeric representation in user's buffer, found ustring
ErrorExpectingNumeric = 9,
/// expecting string representation in user's buffer, found numeric
ErrorExpectingUString = 10,
ErrorInternal = 11, ///< An unrecoverable inconsistent internal state was detected
ErrorBadXMLFormat = 12, ///< E57 primitive not encoded in XML correctly
ErrorXMLParser = 13, ///< XML not well formed
ErrorBadAPIArgument = 14, ///< bad API function argument provided by user
ErrorFileReadOnly = 15, ///< can't modify read only file
ErrorBadChecksum = 16, ///< checksum mismatch, file is corrupted
ErrorOpenFailed = 17, ///< open() failed
ErrorCloseFailed = 18, ///< close() failed
ErrorReadFailed = 19, ///< read() failed
ErrorWriteFailed = 20, ///< write() failed
ErrorSeekFailed = 21, ///< lseek() failed
ErrorPathUndefined = 22, ///< element path well formed but not defined
ErrorBadBuffer = 23, ///< bad SourceDestBuffer
/// no buffer specified for an element in CompressedVectorNode during write
ErrorNoBufferForElement = 24,
ErrorBufferSizeMismatch = 25, ///< SourceDestBuffers not all same size
ErrorBufferDuplicatePathName = 26, ///< duplicate pathname in CompressedVectorNode read/write
ErrorBadFileSignature = 27, ///< file signature not "ASTM-E57"
ErrorUnknownFileVersion = 28, ///< incompatible file version
ErrorBadFileLength = 29, ///< size in file header not same as actual
ErrorXMLParserInit = 30, ///< XML parser failed to initialize
ErrorDuplicateNamespacePrefix = 31, ///< namespace prefix already defined
ErrorDuplicateNamespaceURI = 32, ///< namespace URI already defined
ErrorBadPrototype = 33, ///< bad prototype in CompressedVectorNode
ErrorBadCodecs = 34, ///< bad codecs in CompressedVectorNode
ErrorValueOutOfBounds = 35, ///< element value out of min/max bounds
/// conversion required to assign element value, but not requested
ErrorConversionRequired = 36,
ErrorBadPathName = 37, ///< E57 path name is not well formed
ErrorNotImplemented = 38, ///< functionality not implemented
ErrorBadNodeDowncast = 39, ///< bad downcast from Node to specific node type
ErrorWriterNotOpen = 40, ///< CompressedVectorWriter is no longer open
ErrorReaderNotOpen = 41, ///< CompressedVectorReader is no longer open
ErrorNodeUnattached = 42, ///< node is not yet attached to tree of ImageFile
ErrorAlreadyHasParent = 43, ///< node already has a parent
ErrorDifferentDestImageFile = 44, ///< nodes were constructed with different destImageFiles
ErrorImageFileNotOpen = 45, ///< destImageFile is no longer open
/// SourceDestBuffers not compatible with previously given ones
ErrorBuffersNotCompatible = 46,
ErrorTooManyWriters = 47, ///< too many open CompressedVectorWriters of an ImageFile
ErrorTooManyReaders = 48, ///< too many open CompressedVectorReaders of an ImageFile
ErrorBadConfiguration = 49, ///< bad configuration string
ErrorInvarianceViolation = 50, ///< class invariance constraint violation in debug mode
/// an invalid node type was passed in Data3D pointFields
ErrorInvalidNodeType = 51,
/// passed an invalid value in Data3D pointFields
ErrorInvalidData3DValue = 52,
/// Older versions of this library (and E57RefImpl) incorrectly set the "fileOffset" to 0
/// when "recordCount" is 0. "fileOffset" must be greater than 0 (Table 9 in the standard).
ErrorData3DReadInvalidZeroRecords = 53,
/// @deprecated Will be removed in 4.0. Use e57::Success.
E57_SUCCESS E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use Success." ) = Success,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadCVHeader.
E57_ERROR_BAD_CV_HEADER E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadCVHeader." ) = ErrorBadCVHeader,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadCVPacket.
E57_ERROR_BAD_CV_PACKET E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadCVPacket." ) = ErrorBadCVPacket,
/// @deprecated Will be removed in 4.0. Use e57::ErrorChildIndexOutOfBounds.
E57_ERROR_CHILD_INDEX_OUT_OF_BOUNDS E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorChildIndexOutOfBounds." ) = ErrorChildIndexOutOfBounds,
/// @deprecated Will be removed in 4.0. Use e57::ErrorSetTwice.
E57_ERROR_SET_TWICE E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorSetTwice." ) =
ErrorSetTwice,
/// @deprecated Will be removed in 4.0. Use e57::ErrorHomogeneousViolation.
E57_ERROR_HOMOGENEOUS_VIOLATION E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorHomogeneousViolation." ) = ErrorHomogeneousViolation,
/// @deprecated Will be removed in 4.0. Use e57::ErrorValueNotRepresentable.
E57_ERROR_VALUE_NOT_REPRESENTABLE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorValueNotRepresentable." ) = ErrorValueNotRepresentable,
/// @deprecated Will be removed in 4.0. Use e57::ErrorScaledValueNotRepresentable.
E57_ERROR_SCALED_VALUE_NOT_REPRESENTABLE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorScaledValueNotRepresentable." ) =
ErrorScaledValueNotRepresentable,
/// @deprecated Will be removed in 4.0. Use e57::ErrorReal64TooLarge.
E57_ERROR_REAL64_TOO_LARGE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorReal64TooLarge." ) = ErrorReal64TooLarge,
/// @deprecated Will be removed in 4.0. Use e57::ErrorExpectingNumeric.
E57_ERROR_EXPECTING_NUMERIC E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorExpectingNumeric." ) = ErrorExpectingNumeric,
/// @deprecated Will be removed in 4.0. Use e57::ErrorExpectingUString.
E57_ERROR_EXPECTING_USTRING E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorExpectingUString." ) = ErrorExpectingUString,
/// @deprecated Will be removed in 4.0. Use e57::ErrorInternal.
E57_ERROR_INTERNAL E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorInternal." ) =
ErrorInternal,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadXMLFormat.
E57_ERROR_BAD_XML_FORMAT E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadXMLFormat." ) = ErrorBadXMLFormat,
/// @deprecated Will be removed in 4.0. Use e57::ErrorXMLParser.
E57_ERROR_XML_PARSER E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorXMLParser." ) =
ErrorXMLParser,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadAPIArgument.
E57_ERROR_BAD_API_ARGUMENT E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadAPIArgument." ) = ErrorBadAPIArgument,
/// @deprecated Will be removed in 4.0. Use e57::ErrorFileReadOnly.
E57_ERROR_FILE_IS_READ_ONLY E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorFileReadOnly." ) = ErrorFileReadOnly,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadChecksum.
E57_ERROR_BAD_CHECKSUM E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadChecksum." ) = ErrorBadChecksum,
/// @deprecated Will be removed in 4.0. Use e57::ErrorOpenFailed.
E57_ERROR_OPEN_FAILED E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorOpenFailed." ) =
ErrorOpenFailed,
/// @deprecated Will be removed in 4.0. Use e57::ErrorCloseFailed.
E57_ERROR_CLOSE_FAILED E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorCloseFailed." ) = ErrorCloseFailed,
/// @deprecated Will be removed in 4.0. Use e57::ErrorReadFailed.
E57_ERROR_READ_FAILED E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorReadFailed." ) =
ErrorReadFailed,
/// @deprecated Will be removed in 4.0. Use e57::ErrorWriteFailed.
E57_ERROR_WRITE_FAILED E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorWriteFailed." ) = ErrorWriteFailed,
/// @deprecated Will be removed in 4.0. Use e57::ErrorSeekFailed.
E57_ERROR_LSEEK_FAILED E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorSeekFailed." ) =
ErrorSeekFailed,
/// @deprecated Will be removed in 4.0. Use e57::ErrorPathUndefined.
E57_ERROR_PATH_UNDEFINED E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorPathUndefined." ) = ErrorPathUndefined,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadBuffer.
E57_ERROR_BAD_BUFFER E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorBadBuffer." ) =
ErrorBadBuffer,
/// @deprecated Will be removed in 4.0. Use e57::ErrorNoBufferForElement.
E57_ERROR_NO_BUFFER_FOR_ELEMENT E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorNoBufferForElement." ) = ErrorNoBufferForElement,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBufferSizeMismatch.
E57_ERROR_BUFFER_SIZE_MISMATCH E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBufferSizeMismatch." ) = ErrorBufferSizeMismatch,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBufferDuplicatePathName.
E57_ERROR_BUFFER_DUPLICATE_PATHNAME E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBufferDuplicatePathName." ) =
ErrorBufferDuplicatePathName,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadFileSignature.
E57_ERROR_BAD_FILE_SIGNATURE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadFileSignature." ) = ErrorBadFileSignature,
/// @deprecated Will be removed in 4.0. Use e57::ErrorUnknownFileVersion.
E57_ERROR_UNKNOWN_FILE_VERSION E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorUnknownFileVersion." ) = ErrorUnknownFileVersion,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadFileLength.
E57_ERROR_BAD_FILE_LENGTH E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadFileLength." ) = ErrorBadFileLength,
/// @deprecated Will be removed in 4.0. Use e57::ErrorXMLParserInit.
E57_ERROR_XML_PARSER_INIT E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorXMLParserInit." ) = ErrorXMLParserInit,
/// @deprecated Will be removed in 4.0. Use e57::ErrorDuplicateNamespacePrefix.
E57_ERROR_DUPLICATE_NAMESPACE_PREFIX E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorDuplicateNamespacePrefix." ) =
ErrorDuplicateNamespacePrefix,
/// @deprecated Will be removed in 4.0. Use e57::ErrorDuplicateNamespaceURI.
E57_ERROR_DUPLICATE_NAMESPACE_URI E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorDuplicateNamespaceURI." ) = ErrorDuplicateNamespaceURI,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadPrototype.
E57_ERROR_BAD_PROTOTYPE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadPrototype." ) = ErrorBadPrototype,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadCodecs.
E57_ERROR_BAD_CODECS E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use ErrorBadCodecs." ) =
ErrorBadCodecs,
/// @deprecated Will be removed in 4.0. Use e57::ErrorValueOutOfBounds.
E57_ERROR_VALUE_OUT_OF_BOUNDS E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorValueOutOfBounds." ) = ErrorValueOutOfBounds,
/// @deprecated Will be removed in 4.0. Use e57::ErrorConversionRequired.
E57_ERROR_CONVERSION_REQUIRED E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorConversionRequired." ) = ErrorConversionRequired,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadPathName.
E57_ERROR_BAD_PATH_NAME E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadPathName." ) = ErrorBadPathName,
/// @deprecated Will be removed in 4.0. Use e57::ErrorNotImplemented.
E57_ERROR_NOT_IMPLEMENTED E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorNotImplemented." ) = ErrorNotImplemented,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadNodeDowncast.
E57_ERROR_BAD_NODE_DOWNCAST E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadNodeDowncast." ) = ErrorBadNodeDowncast,
/// @deprecated Will be removed in 4.0. Use e57::ErrorWriterNotOpen.
E57_ERROR_WRITER_NOT_OPEN E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorWriterNotOpen." ) = ErrorWriterNotOpen,
/// @deprecated Will be removed in 4.0. Use e57::ErrorReaderNotOpen.
E57_ERROR_READER_NOT_OPEN E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorReaderNotOpen." ) = ErrorReaderNotOpen,
/// @deprecated Will be removed in 4.0. Use e57::ErrorNodeUnattached.
E57_ERROR_NODE_UNATTACHED E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorNodeUnattached." ) = ErrorNodeUnattached,
/// @deprecated Will be removed in 4.0. Use e57::ErrorAlreadyHasParent.
E57_ERROR_ALREADY_HAS_PARENT E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorAlreadyHasParent." ) = ErrorAlreadyHasParent,
/// @deprecated Will be removed in 4.0. Use e57::ErrorDifferentDestImageFile.
E57_ERROR_DIFFERENT_DEST_IMAGEFILE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorDifferentDestImageFile." ) = ErrorDifferentDestImageFile,
/// @deprecated Will be removed in 4.0. Use e57::ErrorImageFileNotOpen.
E57_ERROR_IMAGEFILE_NOT_OPEN E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorImageFileNotOpen." ) = ErrorImageFileNotOpen,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBuffersNotCompatible.
E57_ERROR_BUFFERS_NOT_COMPATIBLE E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBuffersNotCompatible." ) = ErrorBuffersNotCompatible,
/// @deprecated Will be removed in 4.0. Use e57::ErrorTooManyWriters.
E57_ERROR_TOO_MANY_WRITERS E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorTooManyWriters." ) = ErrorTooManyWriters,
/// @deprecated Will be removed in 4.0. Use e57::ErrorTooManyReaders.
E57_ERROR_TOO_MANY_READERS E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorTooManyReaders." ) = ErrorTooManyReaders,
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadConfiguration.
E57_ERROR_BAD_CONFIGURATION E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorBadConfiguration." ) = ErrorBadConfiguration,
/// @deprecated Will be removed in 4.0. Use e57::ErrorInvarianceViolation.
E57_ERROR_INVARIANCE_VIOLATION E57_DEPRECATED_ENUM(
"Will be removed in 4.0. Use ErrorInvarianceViolation." ) = ErrorInvarianceViolation,
};
namespace Utilities
{
E57_DLL std::string errorCodeToString( ErrorCode ecode ) noexcept;
}
class E57Exception : public std::exception
{
public:
const char *what() const noexcept override
{
return "E57 exception";
}
void report( const char *reportingFileName = nullptr, int reportingLineNumber = 0,
const char *reportingFunctionName = nullptr,
std::ostream &os = std::cout ) const noexcept
{
os << "**** Got an e57 exception: " << errorStr() << std::endl;
#ifdef E57_ENABLE_DIAGNOSTIC_OUTPUT
os << " Debug info: " << std::endl;
os << " context: " << context_ << std::endl;
os << " sourceFunctionName: " << sourceFunctionName_ << std::endl;
if ( reportingFunctionName != nullptr )
{
os << " reportingFunctionName: " << reportingFunctionName << std::endl;
}
/*** Add a line in error message that a smart editor (gnu emacs) can
* interpret as a link to the source code: */
os << sourceFileName_ << "(" << sourceLineNumber_ << ") : error C" << errorCode_
<< ": <--- occurred on" << std::endl;
if ( reportingFileName != nullptr )
{
os << reportingFileName << "(" << reportingLineNumber
<< ") : error C0: <--- reported on" << std::endl;
}
#else
E57_UNUSED( reportingFileName );
E57_UNUSED( reportingLineNumber );
E57_UNUSED( reportingFunctionName );
#endif
}
ErrorCode errorCode() const noexcept
{
return errorCode_;
}
std::string errorStr() const noexcept
{
return Utilities::errorCodeToString( errorCode_ );
}
const std::string &context() const noexcept
{
return context_;
}
// For debugging purposes:
const char *sourceFileName() const noexcept
{
return sourceFileName_.c_str();
}
const char *sourceFunctionName() const noexcept
{
return sourceFunctionName_;
}
int sourceLineNumber() const noexcept
{
return sourceLineNumber_;
}
/// @cond documentNonPublic The following isn't part of the API, and isn't documented.
E57Exception() = delete;
E57Exception( ErrorCode ecode, std::string context, const char *srcFileName = nullptr,
int srcLineNumber = 0, const char *srcFunctionName = nullptr ) :
errorCode_( ecode ), context_( std::move( context ) ), sourceFileName_( srcFileName ),
sourceFunctionName_( srcFunctionName ), sourceLineNumber_( srcLineNumber )
{
}
/// @endcond
private:
/// @cond documentNonPublic The following isn't part of the API, and isn't documented.
ErrorCode errorCode_;
std::string context_;
std::string sourceFileName_;
const char *sourceFunctionName_;
int sourceLineNumber_;
/// @endcond
};
}
|