mesg-foundation / engine

Build apps or autonomous workflows with reusable, shareable integrations connecting any service, app, blockchain or decentralized network.
https://mesg.com/
Apache License 2.0
130 stars 13 forks source link

Use cosmos errors for the backend #1471

Closed antho1404 closed 4 years ago

antho1404 commented 4 years ago

In many places in the sdk backend we use normal errors instead of cosmos errors. We eventually transform these errors into ErrInternal here

So we should consider using directly cosmos errors for the backend as they provide more context ErrInsufficientFunds, ErrInvalidAddress, ErrUnauthorized...

NicolasMahe commented 4 years ago

Even further, the handler functions of sdks should accept classic error and cosmos error type and transform the classic error to cosmos error automatically (like the querier functions)

krhubert commented 4 years ago

So there is a draft (https://github.com/mesg-foundation/engine/pull/1490). We need to decide what errors we want to have and just start using them. I put few example errors. We can create more over the time. Waiting for your commnet.

NicolasMahe commented 4 years ago

After meeting with @krhubert, we decided to implement one new CodespaceType mesg that will contains error related to the project added value (running services, executions, processes) and not to error related to the blockchain (those one should use the sdk codespace defined by cosmos.

We will also implement new CodeType for any error that is not already defined by cosmos.

krhubert commented 4 years ago

As discussed, we're gonna create those errors as needed during development, so closing this issue for now.