Skip to content

Commit 794b9c8

Browse files
authored
Expose the errorDescription var on the CheckoutException class (#19)
* Expose the errorDescription var on the CheckoutException class * Add test
1 parent c68ee52 commit 794b9c8

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ after release for General Availability.
2929

3030
- Adds annotations (`@ColorInt` and `@ColorRes`) for more robust color value enforcement.
3131
- Exposes the `lightColors` and `darkColors` properties of the `Automatic` ColorScheme class to allow overrides.
32+
33+
## 0.3.3 - November 27, 2023
34+
35+
- Exposes the `errorDescription` internal variable on the `CheckoutException` class.

lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def resolveEnvVarValue(name, defaultValue) {
1414
return rawValue ? rawValue : defaultValue
1515
}
1616

17-
def versionName = resolveEnvVarValue("CHECKOUT_KIT_VERSION", "0.3.2")
17+
def versionName = resolveEnvVarValue("CHECKOUT_KIT_VERSION", "0.3.3")
1818

1919
ext {
2020
app_compat_version = '1.6.1'

lib/src/main/java/com/shopify/checkoutkit/CheckoutEventProcessor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import kotlinx.serialization.Serializable
3131
* Superclass for the Shopify Checkout Kit exceptions
3232
*/
3333
@Serializable
34-
public abstract class CheckoutException(private val errorDescription: String) : Exception(errorDescription)
34+
public abstract class CheckoutException(public val errorDescription: String) : Exception(errorDescription)
3535

3636
/**
3737
* Issued when an internal error occurs within Shopify Checkout Kit.

lib/src/test/java/com/shopify/checkoutkit/DefaultCheckoutEventProcessorTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,30 @@ class DefaultCheckoutEventProcessorTest {
101101
verify(log).w("DefaultCheckoutEventProcessor", "Unrecognized scheme for link clicked in checkout 'ftp:lsklsm'")
102102
}
103103

104+
@Test
105+
fun `onCheckoutFailed returns an error description`() {
106+
val log = mock<LogWrapper>()
107+
var description = ""
108+
val processor =
109+
object : DefaultCheckoutEventProcessor(activity, log) {
110+
override fun onCheckoutCompleted() {
111+
/* not implemented */
112+
}
113+
override fun onCheckoutFailed(error: CheckoutException) {
114+
description = error.errorDescription
115+
}
116+
override fun onCheckoutCanceled() {
117+
/* not implemented */
118+
}
119+
}
120+
121+
val error = object : CheckoutException("error description") {}
122+
123+
processor.onCheckoutFailed(error)
124+
125+
assertThat(description).isEqualTo("error description")
126+
}
127+
104128
private fun processor(activity: ComponentActivity): DefaultCheckoutEventProcessor {
105129
return object: DefaultCheckoutEventProcessor(activity) {
106130
override fun onCheckoutCompleted() {/* not implemented */}

0 commit comments

Comments
 (0)