Skip to content

[values4k] Forced message in factory #47

@tkint

Description

@tkint

Hello !

I was wondering, what is the purpose of forcing the message ?

private fun <T> attempt(value: () -> T) = try {
value()
} catch (e: Exception) {
throw IllegalArgumentException(
this::class.java.name.substringBeforeLast('$') +
": " + e::class.java.name + " " + e.localizedMessage
)
}
}

Why not let the client decide what to do with exceptions ?

In my case, I want to throw exceptions in the init of the class, by giving meaningful descriptions. Unfortunately, it gets messed up by this forced behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions