specificityRank

Computes a relative "specificity" rank for this exception handler entry.

This is used as a secondary sort key when ordering exception handlers: handlers are first ordered by descending Priority.priority, and then by this rank in ascending order (lower values are considered more specific).

The ranking scheme is:

  • 0 — handlers that declare both an event and a throwable parameter and have an explicit throwable type recorded via ExceptionHandlerEntryWithThrowable, i.e. methods of the form:

    fun onFailure(event: E, t: T) where T is a specific subtype.

    These are the most specific, as they constrain both the event type and the throwable type.

  • 1 — handlers that are scoped only by event (no explicit throwable parameter), i.e.:

    fun onFailure(event: E)

    These care about which event failed, but not which throwable was thrown.

  • 2 — handlers that are scoped only by throwable, i.e.:

    fun onFailure(t: T)

    These act as global throwable observers and are the least specific with respect to the event that failed.

This ranking is intentionally conservative: it focuses on the presence of an explicit throwable type vs. event-only vs. throwable-only, and is used purely as a tie-breaker within the same priority.

Return

an integer specificity rank where lower values indicate more specific handlers.