Skip to content

Commit 9cc203c

Browse files
committed
Add dedicated exception
1 parent c48b702 commit 9cc203c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

normalized-cache/api/normalized-cache.api

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ public final class com/apollographql/cache/normalized/api/CacheResolverKt {
385385
public static final fun getFieldPolicyCacheResolver ()Lcom/apollographql/cache/normalized/api/CacheResolver;
386386
}
387387

388+
public final class com/apollographql/cache/normalized/api/CannotInlineErrorException : java/lang/RuntimeException {
389+
public fun <init> (Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
390+
public fun getCause ()Ljava/lang/Exception;
391+
public synthetic fun getCause ()Ljava/lang/Throwable;
392+
public final fun getErrorMessage ()Ljava/lang/String;
393+
public final fun getErrorPath ()Ljava/util/List;
394+
public final fun getOperationName ()Ljava/lang/String;
395+
}
396+
388397
public final class com/apollographql/cache/normalized/api/ConnectionEmbeddedFieldsProvider : com/apollographql/cache/normalized/api/EmbeddedFieldsProvider {
389398
public static final field Companion Lcom/apollographql/cache/normalized/api/ConnectionEmbeddedFieldsProvider$Companion;
390399
public fun <init> (Ljava/util/Set;)V

normalized-cache/api/normalized-cache.klib.api

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ final class com.apollographql.cache.normalized.api/CacheKeyGeneratorContext { //
180180
final fun <get-variables>(): com.apollographql.apollo.api/Executable.Variables // com.apollographql.cache.normalized.api/CacheKeyGeneratorContext.variables.<get-variables>|<get-variables>(){}[0]
181181
}
182182

183+
final class com.apollographql.cache.normalized.api/CannotInlineErrorException : kotlin/RuntimeException { // com.apollographql.cache.normalized.api/CannotInlineErrorException|null[0]
184+
constructor <init>(kotlin.collections/List<kotlin/Any>, kotlin/String, kotlin/String, kotlin/Exception) // com.apollographql.cache.normalized.api/CannotInlineErrorException.<init>|<init>(kotlin.collections.List<kotlin.Any>;kotlin.String;kotlin.String;kotlin.Exception){}[0]
185+
186+
final val cause // com.apollographql.cache.normalized.api/CannotInlineErrorException.cause|{}cause[0]
187+
final fun <get-cause>(): kotlin/Exception // com.apollographql.cache.normalized.api/CannotInlineErrorException.cause.<get-cause>|<get-cause>(){}[0]
188+
final val errorMessage // com.apollographql.cache.normalized.api/CannotInlineErrorException.errorMessage|{}errorMessage[0]
189+
final fun <get-errorMessage>(): kotlin/String // com.apollographql.cache.normalized.api/CannotInlineErrorException.errorMessage.<get-errorMessage>|<get-errorMessage>(){}[0]
190+
final val errorPath // com.apollographql.cache.normalized.api/CannotInlineErrorException.errorPath|{}errorPath[0]
191+
final fun <get-errorPath>(): kotlin.collections/List<kotlin/Any> // com.apollographql.cache.normalized.api/CannotInlineErrorException.errorPath.<get-errorPath>|<get-errorPath>(){}[0]
192+
final val operationName // com.apollographql.cache.normalized.api/CannotInlineErrorException.operationName|{}operationName[0]
193+
final fun <get-operationName>(): kotlin/String // com.apollographql.cache.normalized.api/CannotInlineErrorException.operationName.<get-operationName>|<get-operationName>(){}[0]
194+
}
195+
183196
final class com.apollographql.cache.normalized.api/ConnectionEmbeddedFieldsProvider : com.apollographql.cache.normalized.api/EmbeddedFieldsProvider { // com.apollographql.cache.normalized.api/ConnectionEmbeddedFieldsProvider|null[0]
184197
constructor <init>(kotlin.collections/Set<kotlin/String>) // com.apollographql.cache.normalized.api/ConnectionEmbeddedFieldsProvider.<init>|<init>(kotlin.collections.Set<kotlin.String>){}[0]
185198

normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/api/DataWithErrors.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,20 @@ private fun Map<String, ApolloJsonElement>.withErrors(errors: List<Error>?, oper
4747
dataWithErrors.withValueAt(path, error)
4848
} catch (e: Exception) {
4949
// Could not inline error, log and ignore
50-
val message = "Could not inline error at path $path with message \"${error.message}\" for operation '$operationName'"
51-
apolloExceptionHandler(Exception(message, e))
50+
apolloExceptionHandler(CannotInlineErrorException(errorPath = path, errorMessage = error.message, operationName = operationName, cause = e))
5251
dataWithErrors
5352
}
5453
}
5554
return dataWithErrors
5655
}
5756

57+
class CannotInlineErrorException(
58+
val errorPath: List<Any>,
59+
val errorMessage: String,
60+
val operationName: String,
61+
override val cause: Exception,
62+
) : RuntimeException("Could not inline error at path $errorPath with message \"$errorMessage\" for operation '$operationName'", cause)
63+
5864

5965
@Suppress("UNCHECKED_CAST")
6066
private fun Map<String, ApolloJsonElement>.withValueAt(path: List<Any>, value: Any?): DataWithErrors {

0 commit comments

Comments
 (0)