package de.trainingstagebuch.app.utils

import de.trainingstagebuch.app.R

object ErrorMessageFormatter {
    fun dynamicWithOptionalCode(message: String?, code: String?): UiText {
        val normalized = message?.trim().orEmpty()
        if (normalized.isBlank()) {
            return UiText(R.string.error_unknown)
        }
        if (code.isNullOrBlank()) {
            return UiText(
                resId = R.string.error_dynamic,
                args = listOf(normalized)
            )
        }
        return UiText(
            resId = R.string.error_dynamic_with_code,
            args = listOf(normalized, code)
        )
    }
}
