Skip to content

catch in ExceptionHandler require class equality #13

@Alex009

Description

@Alex009

If we use this code:

exceptionHandler.handle { 
    request()
}.catch<Exception> { 
    false
}.execute()

catch blog will not be execute if throw some of subclasses of Exception. it's imprudent behavior, because try-catch allow to catch all subclasses of some type. We should improve it to same logic.


to implement this i think we should remove KClass map and use lambda with conditions.

inline fun <reified E : Throwable> catch(noinline catcher: (E) -> Boolean)

become

inline fun <reified E : Throwable> catch(
    noinline catcher: (E) -> Boolean
): ExceptionHandlerContext<R> {
    return catch(condition = { it is E }, catcher = catcher)
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions