@@ -262,7 +262,7 @@ void addToMap(FunctionDefinition...functions) {
262
262
for (String alias : f .aliases ()) {
263
263
Object old = batchMap .put (alias , f );
264
264
if (old != null || defs .containsKey (alias )) {
265
- throw new IllegalArgumentException ("alias [" + alias + "] is used by "
265
+ throw new SqlIllegalArgumentException ("alias [" + alias + "] is used by "
266
266
+ "[" + (old != null ? old : defs .get (alias ).name ()) + "] and [" + f .name () + "]" );
267
267
}
268
268
aliases .put (alias , f .name ());
@@ -321,10 +321,10 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
321
321
java .util .function .Function <Source , T > ctorRef , String ... names ) {
322
322
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
323
323
if (false == children .isEmpty ()) {
324
- throw new IllegalArgumentException ("expects no arguments" );
324
+ throw new SqlIllegalArgumentException ("expects no arguments" );
325
325
}
326
326
if (distinct ) {
327
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
327
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
328
328
}
329
329
return ctorRef .apply (source );
330
330
};
@@ -341,10 +341,10 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
341
341
ConfigurationAwareFunctionBuilder <T > ctorRef , String ... names ) {
342
342
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
343
343
if (false == children .isEmpty ()) {
344
- throw new IllegalArgumentException ("expects no arguments" );
344
+ throw new SqlIllegalArgumentException ("expects no arguments" );
345
345
}
346
346
if (distinct ) {
347
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
347
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
348
348
}
349
349
return ctorRef .build (source , cfg );
350
350
};
@@ -365,10 +365,10 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
365
365
UnaryConfigurationAwareFunctionBuilder <T > ctorRef , String ... names ) {
366
366
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
367
367
if (children .size () > 1 ) {
368
- throw new IllegalArgumentException ("expects exactly one argument" );
368
+ throw new SqlIllegalArgumentException ("expects exactly one argument" );
369
369
}
370
370
if (distinct ) {
371
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
371
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
372
372
}
373
373
Expression ex = children .size () == 1 ? children .get (0 ) : null ;
374
374
return ctorRef .build (source , ex , cfg );
@@ -390,10 +390,10 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
390
390
BiFunction <Source , Expression , T > ctorRef , String ... names ) {
391
391
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
392
392
if (children .size () != 1 ) {
393
- throw new IllegalArgumentException ("expects exactly one argument" );
393
+ throw new SqlIllegalArgumentException ("expects exactly one argument" );
394
394
}
395
395
if (distinct ) {
396
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
396
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
397
397
}
398
398
return ctorRef .apply (source , children .get (0 ));
399
399
};
@@ -409,7 +409,7 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
409
409
MultiFunctionBuilder <T > ctorRef , String ... names ) {
410
410
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
411
411
if (distinct ) {
412
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
412
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
413
413
}
414
414
return ctorRef .build (source , children );
415
415
};
@@ -429,7 +429,7 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
429
429
DistinctAwareUnaryFunctionBuilder <T > ctorRef , String ... names ) {
430
430
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
431
431
if (children .size () != 1 ) {
432
- throw new IllegalArgumentException ("expects exactly one argument" );
432
+ throw new SqlIllegalArgumentException ("expects exactly one argument" );
433
433
}
434
434
return ctorRef .build (source , children .get (0 ), distinct );
435
435
};
@@ -449,10 +449,10 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
449
449
DatetimeUnaryFunctionBuilder <T > ctorRef , String ... names ) {
450
450
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
451
451
if (children .size () != 1 ) {
452
- throw new IllegalArgumentException ("expects exactly one argument" );
452
+ throw new SqlIllegalArgumentException ("expects exactly one argument" );
453
453
}
454
454
if (distinct ) {
455
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
455
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
456
456
}
457
457
return ctorRef .build (source , children .get (0 ), cfg .zoneId ());
458
458
};
@@ -471,10 +471,10 @@ interface DatetimeUnaryFunctionBuilder<T> {
471
471
static <T extends Function > FunctionDefinition def (Class <T > function , DatetimeBinaryFunctionBuilder <T > ctorRef , String ... names ) {
472
472
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
473
473
if (children .size () != 2 ) {
474
- throw new IllegalArgumentException ("expects exactly two arguments" );
474
+ throw new SqlIllegalArgumentException ("expects exactly two arguments" );
475
475
}
476
476
if (distinct ) {
477
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
477
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
478
478
}
479
479
return ctorRef .build (source , children .get (0 ), children .get (1 ), cfg .zoneId ());
480
480
};
@@ -496,13 +496,13 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
496
496
boolean isBinaryOptionalParamFunction = function .isAssignableFrom (Round .class ) || function .isAssignableFrom (Truncate .class )
497
497
|| TopHits .class .isAssignableFrom (function );
498
498
if (isBinaryOptionalParamFunction && (children .size () > 2 || children .size () < 1 )) {
499
- throw new IllegalArgumentException ("expects one or two arguments" );
499
+ throw new SqlIllegalArgumentException ("expects one or two arguments" );
500
500
} else if (!isBinaryOptionalParamFunction && children .size () != 2 ) {
501
- throw new IllegalArgumentException ("expects exactly two arguments" );
501
+ throw new SqlIllegalArgumentException ("expects exactly two arguments" );
502
502
}
503
503
504
504
if (distinct ) {
505
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
505
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
506
506
}
507
507
return ctorRef .build (source , children .get (0 ), children .size () == 2 ? children .get (1 ) : null );
508
508
};
@@ -527,7 +527,7 @@ private static FunctionDefinition def(Class<? extends Function> function, Functi
527
527
FunctionDefinition .Builder realBuilder = (uf , distinct , cfg ) -> {
528
528
try {
529
529
return builder .build (uf .source (), uf .children (), distinct , cfg );
530
- } catch (IllegalArgumentException e ) {
530
+ } catch (SqlIllegalArgumentException e ) {
531
531
throw new ParsingException (uf .source (), "error building [" + primaryName + "]: " + e .getMessage (), e );
532
532
}
533
533
};
@@ -544,12 +544,12 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
544
544
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
545
545
boolean isLocateFunction = function .isAssignableFrom (Locate .class );
546
546
if (isLocateFunction && (children .size () > 3 || children .size () < 2 )) {
547
- throw new IllegalArgumentException ("expects two or three arguments" );
547
+ throw new SqlIllegalArgumentException ("expects two or three arguments" );
548
548
} else if (!isLocateFunction && children .size () != 3 ) {
549
- throw new IllegalArgumentException ("expects exactly three arguments" );
549
+ throw new SqlIllegalArgumentException ("expects exactly three arguments" );
550
550
}
551
551
if (distinct ) {
552
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
552
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
553
553
}
554
554
return ctorRef .build (source , children .get (0 ), children .get (1 ), children .size () == 3 ? children .get (2 ) : null );
555
555
};
@@ -565,10 +565,10 @@ static <T extends Function> FunctionDefinition def(Class<T> function,
565
565
FourParametersFunctionBuilder <T > ctorRef , String ... names ) {
566
566
FunctionBuilder builder = (source , children , distinct , cfg ) -> {
567
567
if (children .size () != 4 ) {
568
- throw new IllegalArgumentException ("expects exactly four arguments" );
568
+ throw new SqlIllegalArgumentException ("expects exactly four arguments" );
569
569
}
570
570
if (distinct ) {
571
- throw new IllegalArgumentException ("does not support DISTINCT yet it was specified" );
571
+ throw new SqlIllegalArgumentException ("does not support DISTINCT yet it was specified" );
572
572
}
573
573
return ctorRef .build (source , children .get (0 ), children .get (1 ), children .get (2 ), children .get (3 ));
574
574
};
0 commit comments