aptos-core
aptos-core copied to clipboard
[TS][SDK] Convert ApiError into AptosError
The node API, in the error case, invariably returns an AptosError, no matter what. The TS SDK however only returns an ApiError in the non 2xx case. This means the caller is responsible for taking the error body in the ApiError and converting it into an AptosError.
Apparently this is something our generator does not support natively: https://github.com/ferdikoomen/openapi-typescript-codegen/issues/728, https://github.com/ferdikoomen/openapi-typescript-codegen/issues/655. I suspect the best UX (though perhaps a bit messy) would be to postprocess the generated code. One cleanish option would be to add a function to ApiError like intoAptosError
that tries to deserialize the error response body into an AptosError
.
We fork and modify it. https://github.com/aptos-labs/openapi-typescript-codegen. See this https://github.com/aptos-labs/aptos-core/pull/3385
I think we avoid a fork if possible, that's a lot of effort to maintain. I see we already have one but this is a scary road to walk, our repo is already behind.
I don't think that's a lot. Indexer is also using a forked diesel
Yeah I don't love that either lol.
If we do have a fork, we need to hold a high bar, we can't just hack up the codebase because we won't be able to stay on top of upstream.
https://github.com/aptos-labs/aptos-core/pull/2851 is using the fork already. Otherwise, the hack was cumbersome. I had some post-processing and deleted that as it is harder to maintain the postprocessing scripts if there are many.
Alright we'll see how it goes.
This issue is stale because it has been open 45 days with no activity. Remove the stale
label or comment - otherwise this will be closed in 15 days.