Skip to content

Commit b86484d

Browse files
committed
Splits the ErrorBadPathName exception into three separate exceptions (empty, malformed, & extension not registered)
This level of detail would have helped make what happened in #330 obvious. Deprecates ErrorBadPathName in favour of ErrorPathNameEmpty, ErrorPathNameMalformed, and ErrorPathNameExtensionNotRegistered. Note that ErrorPathUndefined is another case that can happen (valid path, not defined).
1 parent 4f7a8c2 commit b86484d

8 files changed

Lines changed: 57 additions & 28 deletions

File tree

include/E57Exception.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ namespace e57
114114
/// conversion required to assign element value, but not requested
115115
ErrorConversionRequired = 36,
116116

117-
ErrorBadPathName = 37, ///< E57 path name is not well formed
117+
/// @deprecated Will be removed in 4.0. Use e57::ErrorPathNameEmpty,
118+
/// e57::ErrorPathNameMalformed, or e57::ErrorPathNameExtensionNotRegistered.
119+
ErrorBadPathName = 37, ///< E57 path name is not well formed
120+
118121
ErrorNotImplemented = 38, ///< functionality not implemented
119122
ErrorBadNodeDowncast = 39, ///< bad downcast from Node to specific node type
120123
ErrorWriterNotOpen = 40, ///< CompressedVectorWriter is no longer open
@@ -142,6 +145,11 @@ namespace e57
142145
/// when "recordCount" is 0. "fileOffset" must be greater than 0 (Table 9 in the standard).
143146
ErrorData3DReadInvalidZeroRecords = 53,
144147

148+
// These refine ErrorBadPathName
149+
ErrorPathNameEmpty, ///< E57 path name is empty
150+
ErrorPathNameMalformed, ///< E57 path name is not well formed
151+
ErrorPathNameExtensionNotRegistered, ///< E57 path name uses an unregistered extension
152+
145153
/// @deprecated Will be removed in 4.0. Use e57::Success.
146154
E57_SUCCESS E57_DEPRECATED_ENUM( "Will be removed in 4.0. Use Success." ) = Success,
147155
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadCVHeader.
@@ -257,7 +265,8 @@ namespace e57
257265
"Will be removed in 4.0. Use ErrorConversionRequired." ) = ErrorConversionRequired,
258266
/// @deprecated Will be removed in 4.0. Use e57::ErrorBadPathName.
259267
E57_ERROR_BAD_PATH_NAME E57_DEPRECATED_ENUM(
260-
"Will be removed in 4.0. Use ErrorBadPathName." ) = ErrorBadPathName,
268+
"Will be removed in 4.0. Use ErrorPathNameEmpty, ErrorPathNameMalformed, or "
269+
"ErrorPathNameExtensionNotRegistered." ) = ErrorBadPathName,
261270
/// @deprecated Will be removed in 4.0. Use e57::ErrorNotImplemented.
262271
E57_ERROR_NOT_IMPLEMENTED E57_DEPRECATED_ENUM(
263272
"Will be removed in 4.0. Use ErrorNotImplemented." ) = ErrorNotImplemented,

src/E57Exception.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ namespace e57
362362
return "trying to read an invalid Data3D with zero records - check for zero records "
363363
"before trying to read this Data3D section (ErrorInvalidZeroRecordsData3D)";
364364

365+
case ErrorPathNameEmpty:
366+
return "E57 path name is empty (ErrorPathNameEmpty)";
367+
case ErrorPathNameMalformed:
368+
return "E57 path name is not well formed (ErrorPathNameMalformed)";
369+
case ErrorPathNameExtensionNotRegistered:
370+
return "E57 path name uses an unregistered extension "
371+
"(ErrorPathNameExtensionNotRegistered)";
372+
365373
default:
366374
return "unknown error (" + std::to_string( ecode ) + ")";
367375
}

src/ImageFile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ prefixed form, the prefix does not have to be declared in the ImageFile.
704704
705705
@post No visible state is modified.
706706
707-
@throw ::ErrorBadPathName (n/c)
707+
@throw ::ErrorPathNameEmpty (n/c)
708+
@throw ::ErrorPathNameMalformed (n/c)
708709
@throw ::ErrorInternal All objects in undocumented state
709710
710711
@see ImageFile::isElementNameExtended

src/ImageFileImpl.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ namespace e57
564564

565565
if ( prefix.length() > 0 && !extensionsLookupPrefix( prefix, uri ) )
566566
{
567-
throw E57_EXCEPTION2( ErrorBadPathName,
567+
throw E57_EXCEPTION2( ErrorPathNameExtensionNotRegistered,
568568
"elementName=" + elementName + " prefix=" + prefix );
569569
}
570570
}
@@ -620,10 +620,10 @@ namespace e57
620620

621621
if ( !isElementNameLegal( elementName ) )
622622
{
623-
throw E57_EXCEPTION2( ErrorBadPathName, std::string( "pathName=" )
624-
.append( pathName )
625-
.append( " elementName=" )
626-
.append( elementName ) );
623+
throw E57_EXCEPTION2( ErrorPathNameMalformed, std::string( "pathName=" )
624+
.append( pathName )
625+
.append( " elementName=" )
626+
.append( elementName ) );
627627
}
628628

629629
// Add to list
@@ -648,7 +648,7 @@ namespace e57
648648
// Empty relative path is not allowed
649649
if ( isRelative && fields.empty() )
650650
{
651-
throw E57_EXCEPTION2( ErrorBadPathName, "pathName=" + pathName );
651+
throw E57_EXCEPTION1( ErrorPathNameEmpty );
652652
}
653653

654654
#ifdef E57_VERBOSE
@@ -712,7 +712,7 @@ namespace e57
712712
// Empty name is bad
713713
if ( len == 0 )
714714
{
715-
throw E57_EXCEPTION2( ErrorBadPathName, "elementName=" + elementName );
715+
throw E57_EXCEPTION1( ErrorPathNameEmpty );
716716
}
717717

718718
unsigned char c = elementName[0];
@@ -727,7 +727,7 @@ namespace e57
727727

728728
if ( c < '0' || c > '9' )
729729
{
730-
throw E57_EXCEPTION2( ErrorBadPathName, "elementName=" + elementName );
730+
throw E57_EXCEPTION2( ErrorPathNameMalformed, "elementName=" + elementName );
731731
}
732732
}
733733

@@ -739,7 +739,7 @@ namespace e57
739739
// Don't allow ':' as first char.
740740
if ( c < 128 && !( ( 'a' <= c && c <= 'z' ) || ( 'A' <= c && c <= 'Z' ) || c == '_' ) )
741741
{
742-
throw E57_EXCEPTION2( ErrorBadPathName, "elementName=" + elementName );
742+
throw E57_EXCEPTION2( ErrorPathNameMalformed, "elementName=" + elementName );
743743
}
744744

745745
// If each following char is ASCII (<128), check for legality
@@ -751,7 +751,7 @@ namespace e57
751751
if ( c < 128 && !( ( 'a' <= c && c <= 'z' ) || ( 'A' <= c && c <= 'Z' ) || c == '_' ||
752752
c == ':' || ( '0' <= c && c <= '9' ) || c == '-' || c == '.' ) )
753753
{
754-
throw E57_EXCEPTION2( ErrorBadPathName, "elementName=" + elementName );
754+
throw E57_EXCEPTION2( ErrorPathNameMalformed, "elementName=" + elementName );
755755
}
756756
}
757757

@@ -763,7 +763,7 @@ namespace e57
763763
// Check doesn't have two colons
764764
if ( elementName.find_first_of( ':', found + 1 ) != std::string::npos )
765765
{
766-
throw E57_EXCEPTION2( ErrorBadPathName, "elementName=" + elementName );
766+
throw E57_EXCEPTION2( ErrorPathNameMalformed, "elementName=" + elementName );
767767
}
768768

769769
// Split element name at the colon
@@ -773,8 +773,9 @@ namespace e57
773773

774774
if ( prefix.length() == 0 || localPart.length() == 0 )
775775
{
776-
throw E57_EXCEPTION2( ErrorBadPathName, "elementName=" + elementName + " prefix=" +
777-
prefix + " localPart=" + localPart );
776+
throw E57_EXCEPTION2( ErrorPathNameMalformed, "elementName=" + elementName +
777+
" prefix=" + prefix +
778+
" localPart=" + localPart );
778779
}
779780
}
780781
else

src/NodeImpl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ void NodeImpl::set( const ustring &pathName, NodeImplSharedPtr ni, bool autoPath
273273
void NodeImpl::set( const StringList & /*fields*/, unsigned /*level*/, NodeImplSharedPtr /*ni*/,
274274
bool /*autoPathCreate*/ )
275275
{
276-
// If get here, then tried to call set(fields...) on NodeImpl that wasn't a StructureNodeImpl,
276+
// If get here, then tried to call set(fields...) on NodeImpl that wasn't a StructureNodeImpl,
277277
// so that's an error
278-
throw E57_EXCEPTION1( ErrorBadPathName ); //???
278+
throw E57_EXCEPTION2( ErrorInternal, "Trying to set a path name on a non-structured node" );
279279
}
280280

281281
void NodeImpl::checkBuffers( const std::vector<SourceDestBuffer> &sdbufs,
@@ -407,7 +407,7 @@ bool NodeImpl::_verifyPathNameAbsolute( const ustring &inPathName )
407407
// If not an absolute path name, have error
408408
if ( isRelative )
409409
{
410-
throw E57_EXCEPTION2( ErrorBadPathName,
410+
throw E57_EXCEPTION2( ErrorPathNameMalformed,
411411
"this->pathName=" + this->pathName() + " pathName=" + inPathName );
412412
}
413413

src/SourceDestBuffer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ transfer with a CompressedVectorNode.
149149
@pre The @a destImageFile must be open (i.e. destImageFile.isOpen() must be true).
150150
@pre The stride must be >= sizeof(*b)
151151
152-
@throw ::ErrorBadAPIArgument (n/c)
153-
@throw ::ErrorBadPathName (n/c)
152+
@throw ::ErrorPathNameEmpty (n/c)
153+
@throw ::ErrorPathNameMalformed (n/c)
154154
@throw ::ErrorBadBuffer (n/c)
155155
@throw ::ErrorImageFileNotOpen (n/c)
156156
@throw ::ErrorInternal All objects in undocumented state
@@ -287,8 +287,8 @@ destroyed).
287287
@pre b.size() must be > 0.
288288
@pre The @a destImageFile must be open (i.e. destImageFile.isOpen() must be true).
289289
290-
@throw ::ErrorBadAPIArgument (n/c)
291-
@throw ::ErrorBadPathName (n/c)
290+
@throw ::ErrorPathNameEmpty (n/c)
291+
@throw ::ErrorPathNameMalformed (n/c)
292292
@throw ::ErrorBadBuffer (n/c)
293293
@throw ::ErrorImageFileNotOpen (n/c)
294294
@throw ::ErrorInternal All objects in undocumented state

src/StructureNode.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ is not attached to an ImageFile, the @a pathName origin root will not the root n
225225
226226
@return true if pathName is currently defined.
227227
228-
@throw ::ErrorBadPathName (n/c)
228+
@throw ::ErrorPathNameEmpty (n/c)
229+
@throw ::ErrorPathNameMalformed (n/c)
230+
@throw ::ErrorPathNameExtensionNotRegistered (n/c)
229231
@throw ::ErrorImageFileNotOpen (n/c)
230232
@throw ::ErrorInternal All objects in undocumented state
231233
@@ -278,7 +280,9 @@ an ImageFile.
278280
279281
@return A smart Node handle referencing the child node.
280282
281-
@throw ::ErrorBadPathName (n/c)
283+
@throw ::ErrorPathNameEmpty (n/c)
284+
@throw ::ErrorPathNameMalformed (n/c)
285+
@throw ::ErrorPathNameExtensionNotRegistered (n/c)
282286
@throw ::ErrorPathUndefined (n/c)
283287
@throw ::ErrorImageFileNotOpen (n/c)
284288
@throw ::ErrorInternal All objects in undocumented state
@@ -322,7 +326,9 @@ destImageFile() == n.destImageFile()).
322326
@post The @a pathName will be defined (i.e. isDefined(pathName)).
323327
324328
@throw ::ErrorImageFileNotOpen (n/c)
325-
@throw ::ErrorBadPathName (n/c)
329+
@throw ::ErrorPathNameEmpty (n/c)
330+
@throw ::ErrorPathNameMalformed (n/c)
331+
@throw ::ErrorPathNameExtensionNotRegistered (n/c)
326332
@throw ::ErrorPathUndefined (n/c)
327333
@throw ::ErrorSetTwice (n/c)
328334
@throw ::ErrorAlreadyHasParent (n/c)

src/VectorNode.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ The element names of child elements of VectorNodes are numbers, encoded as strin
268268
269269
@return true if pathName is currently defined.
270270
271-
@throw ::ErrorBadPathName (n/c)
271+
@throw ::ErrorPathNameEmpty (n/c)
272+
@throw ::ErrorPathNameMalformed (n/c)
273+
@throw ::ErrorPathNameExtensionNotRegistered (n/c)
272274
@throw ::ErrorImageFileNotOpen (n/c)
273275
@throw ::ErrorInternal All objects in undocumented state
274276
@@ -319,7 +321,9 @@ The element names of child elements of VectorNodes are numbers, encoded as strin
319321
320322
@return A smart Node handle referencing the child node.
321323
322-
@throw ::ErrorBadPathName (n/c)
324+
@throw ::ErrorPathNameEmpty (n/c)
325+
@throw ::ErrorPathNameMalformed (n/c)
326+
@throw ::ErrorPathNameExtensionNotRegistered (n/c)
323327
@throw ::ErrorPathUndefined (n/c)
324328
@throw ::ErrorImageFileNotOpen (n/c)
325329
@throw ::ErrorInternal All objects in undocumented state

0 commit comments

Comments
 (0)