`promoCodeGenerationCountExceeded` is false when i...
# announcements
u
promoCodeGenerationCountExceeded
is false when it should be true
n
This does not happen for me (using 1.3.72). I fixed the code (removing extra
,
and
$path
) but that should not make a difference
Also, in the code you showed there is no need for the
get()
and you could just use
val promoCodeGenerationCountExceeded = errorCode == 400 && errorMessage == "PROMO_CODE_COUNT_EXCEEDED"
but I guess the real code is more complex and allows mutating the values?
u
yea sorry its abreviated, there was a path val but yes its not important
well I dont want a field backed val, just a plain getter, hence the get() = ...; no mutating
so ApiException(400, "PROMO_CODE_COUNT_EXCEEDED) returns true for promoCodeGenerationCountExceeded for you on 1.3.72?
Im on the same version
n
yes, it does. I copied and pasted in a Kotlin scratch file:
Code is
Copy code
class ApiException(
    val errorCode: Int,
    val errorMessage: String?
) : RuntimeException(", code '$errorCode', message '$errorMessage'") {
    val promoCodeGenerationCountExceeded
        get() = errorCode == 400 && errorMessage == "PROMO_CODE_COUNT_EXCEEDED"
}

ApiException(400, "PROMO_CODE_COUNT_EXCEEDED").promoCodeGenerationCountExceeded
this returns
true
for me
and this looks identical to your code besides
path
and extra
,
u
then I've no idea whats wrong
n
typo in the string?
unlikely if just addingthe
()
made a difference