growthbook/growthbook-kotlin

GBError visibility modifiers

Closed this issue · 1 comments

At this moment there is no way to get info from GBError except reflection. It is needed at least because you have public fun setRefreshHandler that sets a lambda with error callback.

class GBError(error: Throwable?) {

    /**
     * Error Message for the caught error / exception
     */
    private lateinit var errorMessage: String

    /**
     * Error Stacktrace for the caught error / exception
     */
    private lateinit var stackTrace: String

    /**
     * Constructor for initializing
     */
    init {
        if (error != null) {
            errorMessage = error.message ?: ""
            stackTrace = error.stackTraceToString()
        }
    }
}

Any solution is applicable: make the error into a data class, override toString() method or make fields public; but any of the solutions require errorMessage/stackTrace not to be lateinit, so there is no need for null check around initialization, and init can look like this.

    init {
        errorMessage = error?.message ?: ""
        stackTrace = error?.stackTraceToString() ?: ""
    }

Hello @VeeronTen!
Thank you for reporting this issue.
The pull request was created according to this issue