Skip to content

Consider using typed throws on methods that always throw ClientError/ServerError #844

@czechboy0

Description

@czechboy0

Consider using typed throws on methods that always throw ClientError/ServerError.

This will allow adopters to remove an extra } catch { that doesn't have clear purpose.

do {
    _ = try await try await client.getGreeting(input: ...)
} catch as ClientError {
    // This branch is always taken
} catch {
    // This branch is never taken, we always throw ClientError
}

Similar on the server.

With typed throws, we'll be able to do:

do {
    _ = try await try await client.getGreeting(input: ...)
} catch {
    // This branch is always taken and error is statically known to be ClientError
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/generatorAffects: plugin, CLI, config file.area/runtimeAffects: the runtime library.kind/enhancementImprovements to existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions