-
Notifications
You must be signed in to change notification settings - Fork 124
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
Clean up Api Error and indicate future status clearly #424
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,30 +15,45 @@ | |
|
||
*/ | ||
|
||
use crate::{api::XtStatus, rpc::Error as RpcClientError}; | ||
use crate::{api::UnexpectedTxStatus, rpc::Error as RpcClientError}; | ||
use ac_node_api::{ | ||
error::DispatchError, | ||
metadata::{InvalidMetadataError, MetadataError}, | ||
DispatchError, | ||
}; | ||
use alloc::{boxed::Box, string::String}; | ||
use alloc::boxed::Box; | ||
|
||
pub type Result<T> = core::result::Result<T, Error>; | ||
|
||
#[derive(Debug, derive_more::From)] | ||
pub enum Error { | ||
/// Could not fetch the genesis hash from node. | ||
FetchGenesisHash, | ||
/// Expected a signer, but none is assigned. | ||
NoSigner, | ||
/// Rpc Client Error. | ||
RpcClient(RpcClientError), | ||
/// Metadata Error. | ||
Metadata(MetadataError), | ||
/// Invalid Metadata Error. | ||
InvalidMetadata(InvalidMetadataError), | ||
/// Node Api Error. | ||
NodeApi(ac_node_api::error::Error), | ||
StorageValueDecode(codec::Error), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed to Codec, as it's already used for general decoding errors, not just StorageValue. |
||
UnsupportedXtStatus(XtStatus), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed, as it was not used at all. |
||
/// Encode / Decode Error. | ||
Codec(codec::Error), | ||
/// Could not convert NumberOrHex with try_from. | ||
TryFromIntError, | ||
/// Node Api Dispatch Error. | ||
Dispatch(DispatchError), | ||
Extrinsic(String), | ||
/// Encountered unexpected tx status during watch process. | ||
UnexpectedTxStatus(UnexpectedTxStatus), | ||
/// Could not send update because the Stream has been closed unexpectedly. | ||
NoStream, | ||
NoBlockHash, | ||
NoBlock, | ||
/// Could not find the expected extrinsic. | ||
ExtrinsicNotFound, | ||
/// Could not find the expected block hash. | ||
BlockHashNotFound, | ||
/// Could not find the expected block. | ||
BlockNotFound, | ||
/// Any custom Error. | ||
Other(Box<dyn core::error::Error + Send + Sync + 'static>), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to remove this one because in the api the node-api is also rexported with pub use ..::*; The default error should be the one from api-client, not the node-api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, in general I think we should be more conscious about exports anyhow than just wildcard re-exporting anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. Let me take that into an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#430 :) Thanks for the input