Skip to content

Conversation

@Jozott00
Copy link
Collaborator

Subsystem
gRPC

Problem Description
The current StatusException API is far from Kotlin idiomatic.

Solution
Because StatusException is tightly coupled with the Java StatusException as it is just a typealias, we have some constraints in regard to changes of the implementation.

This PR tries to address the most inconvenient parts of the current API by using extension functions:

  • StatusException.status
  • StatusException.trailers
  • Status.description
  • Status.statusCode
  • StatusCode.asException
  • StatusCode.asStatus
  • Status.asException

@Jozott00 Jozott00 self-assigned this Nov 24, 2025
@Jozott00 Jozott00 added the feature New feature or request label Nov 24, 2025
@Jozott00 Jozott00 requested a review from Mr3zee November 24, 2025 11:55
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

*/
public val Status.description: String? get() = getDescription()

// this is currently @InternalRpcApi as it's behavior would be inconsistent between JVM and Native.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the inconsistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some APIs in Java attach the causing exception. However, on native, we would lose the causing exception information as we can't pass it through the C layer. So I think it might be better to just omit it, so users don't rely on the cause value of the Status exception.

@Jozott00 Jozott00 merged commit ba8fca7 into grpc-common Nov 25, 2025
7 of 8 checks passed
@Jozott00 Jozott00 deleted the grpc/status-exception branch November 25, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants