package com.example.modifier.exception

class RequestNumberException(code: Int) : Exception() {
    override val message: String?

    companion object {
        object ErrorCode {
            const val CODE_NUMBER_EXPIRED = 100
            const val CODE_TIMEOUT_TOO_SHORT = 101
            const val CODE_RCS_TOGGLED_OFF = 102
            const val CODE_REPLAY_RETRY = 103
            const val CODE_OTP_NOT_SENT = 104
            const val CODE_OTP_NOT_RECEIVED = 105
            const val CODE_OTP_VERIFY_FAILED = 106
        }
    }

    init {
        when (code) {
            ErrorCode.CODE_NUMBER_EXPIRED -> {
                message = "Number expired"
            }

            ErrorCode.CODE_TIMEOUT_TOO_SHORT -> {
                message = "OTP timeout too short"
            }

            ErrorCode.CODE_RCS_TOGGLED_OFF -> {
                message = "RCS toggled off or disappeared"
            }

            ErrorCode.CODE_REPLAY_RETRY -> {
                message = "REPLAY_REQUEST or RETRY detected, may reset after 3 retry"
            }

            ErrorCode.CODE_OTP_NOT_SENT -> {
                message = "OTP not sent"
            }

            ErrorCode.CODE_OTP_NOT_RECEIVED -> {
                message = "OTP not received"
            }

            ErrorCode.CODE_OTP_VERIFY_FAILED -> {
                message = "OTP verify failed"
            }

            else -> {
                message = "Unknown error"
            }
        }
    }

}