All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tairitsu.ignotus.exception.business.PageSizeInvalidException.kt Maven / Gradle / Ivy

There is a newer version: 1.0.32
Show newest version
package com.tairitsu.ignotus.exception.business

import com.tairitsu.ignotus.exception.SingleApiException

/**
 * 业务异常:页大小格式错误
 */
class PageSizeInvalidException(parameterName: String, reason: Reason, minLimit: Int = 0, maxLimit: Int = 0) : SingleApiException(404, CODE, "") {
    companion object {
        const val CODE = "page_size_invalid"
    }

    enum class Reason(val s: String) {
        FAIL_TO_PARSE("fail_to_parse"),
        OUT_OF_RANGE("out_of_range"),
    }

    init {
        this.title = Translation.translateTitle(CODE)

        this.detail = when (reason) {
            Reason.FAIL_TO_PARSE -> Translation.translateDetail(CODE, reason.s)
            Reason.OUT_OF_RANGE -> Translation.translateDetail(CODE, reason.s, mapOf("min" to minLimit, "max" to maxLimit))
        }

        val t = HashMap()
        this.source = t
        t["parameter"] = parameterName
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy