3939import java .util .Map ;
4040import org .neo4j .driver .Value ;
4141import org .neo4j .driver .exceptions .ClientException ;
42+ import org .neo4j .driver .exceptions .ProtocolException ;
4243import org .neo4j .driver .internal .InternalNode ;
4344import org .neo4j .driver .internal .InternalPath ;
4445import org .neo4j .driver .internal .InternalRelationship ;
@@ -188,21 +189,29 @@ protected Value unpackStruct(long size, byte type) throws IOException {
188189 if (!dateTimeUtcEnabled ) {
189190 ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
190191 return unpackDateTimeWithZoneOffset ();
192+ } else {
193+ throw instantiateExceptionForUnknownType (type );
191194 }
192195 case DATE_TIME_WITH_ZONE_OFFSET_UTC :
193196 if (dateTimeUtcEnabled ) {
194197 ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
195198 return unpackDateTimeUtcWithZoneOffset ();
199+ } else {
200+ throw instantiateExceptionForUnknownType (type );
196201 }
197202 case DATE_TIME_WITH_ZONE_ID :
198203 if (!dateTimeUtcEnabled ) {
199204 ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
200205 return unpackDateTimeWithZoneId ();
206+ } else {
207+ throw instantiateExceptionForUnknownType (type );
201208 }
202209 case DATE_TIME_WITH_ZONE_ID_UTC :
203210 if (dateTimeUtcEnabled ) {
204211 ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
205212 return unpackDateTimeUtcWithZoneId ();
213+ } else {
214+ throw instantiateExceptionForUnknownType (type );
206215 }
207216 case DURATION :
208217 ensureCorrectStructSize (TypeConstructor .DURATION , DURATION_TIME_STRUCT_SIZE , size );
@@ -224,7 +233,7 @@ protected Value unpackStruct(long size, byte type) throws IOException {
224233 ensureCorrectStructSize (TypeConstructor .PATH , 3 , size );
225234 return unpackPath ();
226235 default :
227- throw new IOException ( "Unknown struct type: " + type );
236+ throw instantiateExceptionForUnknownType ( type );
228237 }
229238 }
230239
@@ -417,4 +426,8 @@ private ZonedDateTime newZonedDateTimeUsingUtcBaseline(long epochSecondLocal, in
417426 LocalDateTime localDateTime = LocalDateTime .ofInstant (instant , zoneId );
418427 return ZonedDateTime .of (localDateTime , zoneId );
419428 }
429+
430+ private ProtocolException instantiateExceptionForUnknownType (byte type ) {
431+ return new ProtocolException ("Unknown struct type: " + type );
432+ }
420433}
0 commit comments