Skip to content

Commit 4a4c0e2

Browse files
committed
Gardening: align Scala exception with Java
Use the same exception type as Java does. This is partly to help FIT validation, which detects "illegal" within transaction logging as indicative of a bug. And also to align with SDK-RFC. Change-Id: I0bd952540f89b2321ec5c1d79b0b2d0dca23d585 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/228740 Tested-by: Build Bot <[email protected]> Reviewed-by: David Nault <[email protected]>
1 parent 97c61f6 commit 4a4c0e2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scala-implicits/src/main/scala/com/couchbase/client/scala/codec/JsonTranscoder.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.couchbase.client.scala.codec
1717

18+
import com.couchbase.client.core.error.InvalidArgumentException
1819
import com.couchbase.client.core.msg.kv.CodecFlags
1920

2021
import scala.reflect.ClassTag
@@ -26,10 +27,10 @@ class JsonTranscoder() extends TranscoderWithSerializer {
2627
value match {
2728
case x: Array[Byte] =>
2829
Failure(
29-
new IllegalArgumentException(
30+
new InvalidArgumentException(
3031
"byte[] input is not supported for the " +
3132
"JsonTranscoder! If you want to store already encoded JSON, use the RawJsonTranscoder, otherwise store " +
32-
"it with the RawBinaryTranscoder!"
33+
"it with the RawBinaryTranscoder!", null, null
3334
)
3435
)
3536
case _ =>
@@ -44,10 +45,10 @@ class JsonTranscoder() extends TranscoderWithSerializer {
4445
): Try[T] = {
4546
if (tag.runtimeClass.isAssignableFrom(classOf[Array[Byte]])) {
4647
Failure(
47-
new IllegalArgumentException(
48+
new InvalidArgumentException(
4849
"Array[Byte] input is not supported for the JsonTranscoder!. " +
4950
"If you want to read already encoded JSON, use the RawJsonTranscoder, otherwise read it " +
50-
"with the RawBinaryTranscoder!"
51+
"with the RawBinaryTranscoder!", null, null
5152
)
5253
)
5354
} else {

0 commit comments

Comments
 (0)