Remove all unwrap calls.

This commit is contained in:
FireMasterK 2021-04-30 11:23:49 +05:30
parent ed6b94dc2d
commit dabd19981c
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58

View file

@ -24,7 +24,7 @@ pub mod piped {
.text() .text()
.await?; .await?;
let streams: Vec<RelatedStream> = serde_json::from_str(resp.as_str()).unwrap(); let streams: Vec<RelatedStream> = serde_json::from_str(resp.as_str())?;
Ok(streams) Ok(streams)
} }
@ -41,7 +41,7 @@ pub mod piped {
.text() .text()
.await?; .await?;
let channel: Channel = serde_json::from_str(resp.as_str()).unwrap(); let channel: Channel = serde_json::from_str(resp.as_str())?;
Ok(channel) Ok(channel)
} }
@ -53,8 +53,7 @@ pub mod piped {
nextbody: String, nextbody: String,
) -> Result<StreamsPage, Box<dyn std::error::Error>> { ) -> Result<StreamsPage, Box<dyn std::error::Error>> {
let mut url = let mut url =
Url::parse(format!("{}/nextpage/channels/{}", &self.instance, id).as_str()) Url::parse(format!("{}/nextpage/channels/{}", &self.instance, id).as_str())?;
.unwrap();
url.query_pairs_mut() url.query_pairs_mut()
.append_pair("url", nexturl.as_str()) .append_pair("url", nexturl.as_str())
.append_pair("id", nextbody.as_str()); .append_pair("id", nextbody.as_str());
@ -67,7 +66,7 @@ pub mod piped {
.text() .text()
.await?; .await?;
let streams: StreamsPage = serde_json::from_str(resp.as_str()).unwrap(); let streams: StreamsPage = serde_json::from_str(resp.as_str())?;
Ok(streams) Ok(streams)
} }
@ -84,7 +83,7 @@ pub mod piped {
.text() .text()
.await?; .await?;
let playlist: Playlist = serde_json::from_str(resp.as_str()).unwrap(); let playlist: Playlist = serde_json::from_str(resp.as_str())?;
Ok(playlist) Ok(playlist)
} }
@ -96,8 +95,7 @@ pub mod piped {
nextbody: String, nextbody: String,
) -> Result<StreamsPage, Box<dyn std::error::Error>> { ) -> Result<StreamsPage, Box<dyn std::error::Error>> {
let mut url = let mut url =
Url::parse(format!("{}/nextpage/playlists/{}", &self.instance, id).as_str()) Url::parse(format!("{}/nextpage/playlists/{}", &self.instance, id).as_str())?;
.unwrap();
url.query_pairs_mut() url.query_pairs_mut()
.append_pair("url", nexturl.as_str()) .append_pair("url", nexturl.as_str())
.append_pair("id", nextbody.as_str()); .append_pair("id", nextbody.as_str());
@ -110,7 +108,7 @@ pub mod piped {
.text() .text()
.await?; .await?;
let streams: StreamsPage = serde_json::from_str(resp.as_str()).unwrap(); let streams: StreamsPage = serde_json::from_str(resp.as_str())?;
Ok(streams) Ok(streams)
} }