YorkieException

open class YorkieException(val code: YorkieException.Code, val errorMessage: String) : RuntimeException

YorkieError is an error returned by a Yorkie operation.

This was a data class until ChangeApplyError (JS 4251ab7e, #1403) needed to extend it: a data class cannot be a supertype in Kotlin, so this is now a public open class with the exact same public surface hand-written back in — equals/hashCode/toString reproduce the data-class text/semantics, copy and component1/component2 behave the same way for a plain YorkieException. equals additionally compares the runtime class, so a ChangeApplyError is never equal to a plain YorkieException with the same code and errorMessage. copy always returns a plain YorkieException — even when called on a subclass — because a subclass such as ChangeApplyError carries additional state (cause, changeID, ...) that a generic copy cannot reconstruct; this is a deliberate, documented divergence from a data class's generated copy. Pinned by YorkieExceptionCompatTest.

Discriminate a caught YorkieException by is ChangeApplyError, not by code: a future error type could reuse a Code value, but the runtime type is exact.

Inheritors

Constructors

Link copied to clipboard
constructor(code: YorkieException.Code, errorMessage: String)

Types

Link copied to clipboard

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val message: String?

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
operator fun component2(): String
Link copied to clipboard
fun copy(code: YorkieException.Code = this.code, errorMessage: String = this.errorMessage): YorkieException

Returns a plain YorkieException with the given code and errorMessage, each defaulting to this instance's own value. Unlike a data class's generated copy, this always constructs the base YorkieException type, even when called on a subclass such as ChangeApplyError (documented divergence, see the class KDoc above).

Link copied to clipboard
operator override fun equals(other: Any?): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override fun hashCode(): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override fun toString(): String

Reproduces the data-class text YorkieException(code=…, errorMessage=…) for a plain YorkieException — a hard-coded literal, NOT javaClass.simpleName, so the base class's own name stays byte-identical to the pre-open-class data-class output even under R8 minification in a consumer app with no keep rule for it (a review finding on the change apply error: javaClass.simpleName alone is not R8-stable). A subclass — e.g. ChangeApplyError(code=…, errorMessage=…) — still uses Any.javaClass/Class.getSimpleName, so its OWN name can be obfuscated by R8 in a consumer app without a keep rule for that subclass; a consumer-rules follow-up (e.g. a -keep entry, or extending the literal approach to subclasses) is intentionally not added here, out of this fix's scope.