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

client builder: return a ClientBuildError when failing to build, instead of filtering out unexpected errors #4016

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions crates/matrix-sdk/src/client/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,19 +709,6 @@ pub enum ClientBuildError {
SqliteStore(#[from] matrix_sdk_sqlite::OpenStoreError),
}

impl ClientBuildError {
/// Assert that a valid homeserver URL was given to the builder and no other
/// invalid options were specified, which means the only possible error
/// case is [`Self::Http`].
#[doc(hidden)]
pub fn assert_valid_builder_args(self) -> HttpError {
match self {
ClientBuildError::Http(e) => e,
_ => unreachable!("homeserver URL was asserted to be valid"),
}
}
}

// The http mocking library is not supported for wasm32
#[cfg(all(test, not(target_arch = "wasm32")))]
pub(crate) mod tests {
Expand Down
8 changes: 2 additions & 6 deletions crates/matrix-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,8 @@ impl Client {
/// # Arguments
///
/// * `homeserver_url` - The homeserver that the client should connect to.
pub async fn new(homeserver_url: Url) -> Result<Self, HttpError> {
Self::builder()
.homeserver_url(homeserver_url)
.build()
.await
.map_err(ClientBuildError::assert_valid_builder_args)
pub async fn new(homeserver_url: Url) -> Result<Self, ClientBuildError> {
Self::builder().homeserver_url(homeserver_url).build().await
}

/// Returns a subscriber that publishes an event every time the ignore user
Expand Down
Loading