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

chore: exposing ErrCode class #158

Merged
merged 3 commits into from
Jul 24, 2024
Merged

Conversation

iuricmp
Copy link
Contributor

@iuricmp iuricmp commented Jul 24, 2024

Expose ErrCode class and add rpc_pb to exports.
Useful for client who wants to implements error checks on their dApps, eg:

import { ErrCode } from "@gnolang/gnonative";  

if (err.errCode() === ErrCode.ErrDecryptionFailed) {
  setError("Wrong password, please try again.");
}

Signed-off-by: Iuri Pereira <689440+iuricmp@users.noreply.github.com>
@iuricmp iuricmp requested review from D4ryl00 and jefft0 July 24, 2024 11:44
Copy link
Contributor

@jefft0 jefft0 left a comment

Choose a reason for hiding this comment

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

LGTM. I assume this will be tested in dSocial.

Signed-off-by: Iuri Pereira <689440+iuricmp@users.noreply.github.com>
Signed-off-by: D4ryl00 <d4ryl00@gmail.com>
@D4ryl00
Copy link
Contributor

D4ryl00 commented Jul 24, 2024

tested in Android and iOS with this code in a catch block:

try {
...
} catch (error) {
	if (error instanceof ConnectError) {
	  const err = new GRPCError(error);
	  if (err.errCode() === ErrCode.ErrBridgeInterrupted) {
	    console.log('err catched');
	  }
	} else {
	  console.log(error);
	}
}

@iuricmp iuricmp merged commit aea0cd1 into gnolang:main Jul 24, 2024
@iuricmp iuricmp deleted the chore/exposing-ErrCode branch July 24, 2024 15:31
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