@@ -235,7 +235,8 @@ protected Builder(Class<P> returnClass) {
235235 protected abstract THIS self ();
236236
237237 protected final THIS repetition (Type .Repetition repetition ) {
238- Preconditions .checkArgument (!repetitionAlreadySet , "Repetition has already been set" );
238+ Preconditions .checkArgument (
239+ !repetitionAlreadySet , "Repetition has already been set to: %s" , this .repetition );
239240 this .repetition = Objects .requireNonNull (repetition , "Repetition cannot be null" );
240241 this .repetitionAlreadySet = true ;
241242 return self ();
@@ -656,20 +657,27 @@ protected DecimalMetadata decimalMetadata() {
656657 if (scaleAlreadySet ) {
657658 Preconditions .checkArgument (
658659 this .scale == decimalType .getScale (),
659- "Decimal scale should match with the scale of the logical type" );
660+ "Decimal scale should match with the scale of the logical type. Expected: %s, but was: %s" ,
661+ decimalType .getScale (),
662+ this .scale );
660663 }
661664 if (precisionAlreadySet ) {
662665 Preconditions .checkArgument (
663666 this .precision == decimalType .getPrecision (),
664- "Decimal precision should match with the precision of the logical type" );
667+ "Decimal precision should match with the precision of the logical type. Expected: %s, but was: %s" ,
668+ decimalType .getPrecision (),
669+ this .precision );
665670 }
666671 scale = decimalType .getScale ();
667672 precision = decimalType .getPrecision ();
668673 }
669674 Preconditions .checkArgument (precision > 0 , "Invalid DECIMAL precision: %s" , precision );
670675 Preconditions .checkArgument (this .scale >= 0 , "Invalid DECIMAL scale: %s" , this .scale );
671676 Preconditions .checkArgument (
672- this .scale <= precision , "Invalid DECIMAL scale: cannot be greater than precision" );
677+ this .scale <= precision ,
678+ "Invalid DECIMAL scale: %s cannot be greater than precision: %s" ,
679+ this .scale ,
680+ precision );
673681 meta = new DecimalMetadata (precision , scale );
674682 }
675683 return meta ;
@@ -1115,12 +1123,18 @@ protected ListValueBuilder<MP, M> self() {
11151123 }
11161124
11171125 protected void setKeyType (Type keyType ) {
1118- Preconditions .checkState (this .keyType == null , "Only one key type can be built with a MapBuilder" );
1126+ Preconditions .checkState (
1127+ this .keyType == null ,
1128+ "Only one key type can be built with a MapBuilder, but found existing type: %s" ,
1129+ this .keyType );
11191130 this .keyType = keyType ;
11201131 }
11211132
11221133 protected void setValueType (Type valueType ) {
1123- Preconditions .checkState (this .valueType == null , "Only one key type can be built with a ValueBuilder" );
1134+ Preconditions .checkState (
1135+ this .valueType == null ,
1136+ "Only one value type can be built with a ValueBuilder, but found existing type: %s" ,
1137+ this .valueType );
11241138 this .valueType = valueType ;
11251139 }
11261140
@@ -1207,7 +1221,9 @@ public THIS value(Type type) {
12071221 @ Override
12081222 protected Type build (String name ) {
12091223 Preconditions .checkState (
1210- logicalTypeAnnotation == null , "MAP is already a logical type and can't be changed." );
1224+ logicalTypeAnnotation == null ,
1225+ "MAP is already a logical type and can't be changed. Current annotation: %s" ,
1226+ logicalTypeAnnotation );
12111227 if (keyType == null ) {
12121228 keyType = STRING_KEY ;
12131229 }
@@ -1260,7 +1276,10 @@ public BaseListBuilder(Class<P> returnType) {
12601276 }
12611277
12621278 public THIS setElementType (Type elementType ) {
1263- Preconditions .checkState (this .elementType == null , "Only one element can be built with a ListBuilder" );
1279+ Preconditions .checkState (
1280+ this .elementType == null ,
1281+ "Only one element can be built with a ListBuilder, but found existing type: %s" ,
1282+ this .elementType );
12641283 this .elementType = elementType ;
12651284 return self ();
12661285 }
@@ -1357,7 +1376,9 @@ public LP named(String name) {
13571376 @ Override
13581377 protected Type build (String name ) {
13591378 Preconditions .checkState (
1360- logicalTypeAnnotation == null , "LIST is already the logical type and can't be changed" );
1379+ logicalTypeAnnotation == null ,
1380+ "LIST is already the logical type and can't be changed. Current annotation: %s" ,
1381+ logicalTypeAnnotation );
13611382 Objects .requireNonNull (elementType , "List element type cannot be null" );
13621383
13631384 GroupBuilder <GroupType > builder = buildGroup (repetition ).as (OriginalType .LIST );
0 commit comments