Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple from UniFFI code-gen'd Web5Exception #334

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

KendallWeihe
Copy link
Contributor

this is the last piece to completely decouple us from uniffi codegen at the api surface

also fixed the Dsa which was still a lingering coupling

enum class Dsa {
ED25519,
SECP256K1;
}

internal fun dsaFromRustCore(rustCore: RustCoreDsa): Dsa {
Copy link
Contributor

Choose a reason for hiding this comment

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

perfect

@@ -14,8 +16,14 @@ class Ed25519Generator {
* @return Jwk the JWK with private key material included.
*/
fun generate(): Jwk {
Copy link
Contributor

Choose a reason for hiding this comment

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

chad says:
You can simplify the generate() function by removing the redundant catch block for the generic Exception, as it will automatically be propagated if not caught.

Copy link
Contributor

Choose a reason for hiding this comment

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

also since there are a lot of these it could be cleaner to do it this way with return try:

    return try {
        val rustCoreJwkData = ed25519GeneratorGenerate()
        Jwk.fromRustCoreJwkData(rustCoreJwkData)
    } catch (e: RustCoreException) {
        throw Web5Exception.fromRustCore(e)
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch! done

@nitro-neal
Copy link
Contributor

added this issue to investigate further for less verbose exception handling - #335

@KendallWeihe KendallWeihe force-pushed the kendall/decouple-uniffi-web5exception branch from 9d6d3b5 to e484f59 Compare September 4, 2024 13:19
@KendallWeihe KendallWeihe merged commit ad6761f into main Sep 4, 2024
21 checks passed
@KendallWeihe KendallWeihe deleted the kendall/decouple-uniffi-web5exception branch September 4, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants