39
39
import java .util .Map ;
40
40
import org .neo4j .driver .Value ;
41
41
import org .neo4j .driver .exceptions .ClientException ;
42
+ import org .neo4j .driver .exceptions .ProtocolException ;
42
43
import org .neo4j .driver .internal .InternalNode ;
43
44
import org .neo4j .driver .internal .InternalPath ;
44
45
import org .neo4j .driver .internal .InternalRelationship ;
@@ -189,21 +190,29 @@ private Value unpackStruct(long size, byte type) throws IOException {
189
190
if (!dateTimeUtcEnabled ) {
190
191
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
191
192
return unpackDateTimeWithZoneOffset ();
193
+ } else {
194
+ throw instantiateExceptionForUnknownType (type );
192
195
}
193
196
case DATE_TIME_WITH_ZONE_OFFSET_UTC :
194
197
if (dateTimeUtcEnabled ) {
195
198
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
196
199
return unpackDateTimeUtcWithZoneOffset ();
200
+ } else {
201
+ throw instantiateExceptionForUnknownType (type );
197
202
}
198
203
case DATE_TIME_WITH_ZONE_ID :
199
204
if (!dateTimeUtcEnabled ) {
200
205
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
201
206
return unpackDateTimeWithZoneId ();
207
+ } else {
208
+ throw instantiateExceptionForUnknownType (type );
202
209
}
203
210
case DATE_TIME_WITH_ZONE_ID_UTC :
204
211
if (dateTimeUtcEnabled ) {
205
212
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
206
213
return unpackDateTimeUtcWithZoneId ();
214
+ } else {
215
+ throw instantiateExceptionForUnknownType (type );
207
216
}
208
217
case DURATION :
209
218
ensureCorrectStructSize (TypeConstructor .DURATION , DURATION_TIME_STRUCT_SIZE , size );
@@ -225,7 +234,7 @@ private Value unpackStruct(long size, byte type) throws IOException {
225
234
ensureCorrectStructSize (TypeConstructor .PATH , 3 , size );
226
235
return unpackPath ();
227
236
default :
228
- throw new IOException ( "Unknown struct type: " + type );
237
+ throw instantiateExceptionForUnknownType ( type );
229
238
}
230
239
}
231
240
@@ -430,6 +439,10 @@ private ZonedDateTime newZonedDateTimeUsingUtcBaseline(long epochSecondLocal, in
430
439
return ZonedDateTime .of (localDateTime , zoneId );
431
440
}
432
441
442
+ private ProtocolException instantiateExceptionForUnknownType (byte type ) {
443
+ return new ProtocolException ("Unknown struct type: " + type );
444
+ }
445
+
433
446
protected int getNodeFields () {
434
447
return NODE_FIELDS ;
435
448
}
0 commit comments