Skip to content

Provide Hint in beforeSend hook #84

Open
@Legion2

Description

@Legion2

Currently it is very difficult to filter exceptions in common kotlin code, because we don't have access to the original exception object which causes the event. We need to compare the type name and package name of the exceptions as strings. What normally is a simple hint is MyException is turned into

inline fun <reified T> SentryException.isOfType(): Boolean {
    val qualifiedName = T::class.qualifiedName ?: error("Cannot get qualified name of ${T::class}")
    val module = qualifiedName.substringBeforeLast(".")
    val type = qualifiedName.substringAfterLast(".")
    return module == this.module && type == this.type
}

But this does not work for exception subtypes, so if there is an exception which is a subtype of MyException it is impossible to filter this with the current beforeSend because one had to know all subtypes to handle them all individually.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions