Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
initialize app with clipboardcontext
  • Loading branch information
LennyPenny committed Nov 19, 2019
commit a878413ec2e8c16caa5f1ae3767dd13e7ed58785
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod util;

use backtrace::Backtrace;
use clap::App as ClapApp;
use failure::format_err;
use rspotify::spotify::client::Spotify;
use rspotify::spotify::oauth2::{SpotifyClientCredentials, SpotifyOAuth, TokenInfo};
use rspotify::spotify::util::get_token;
Expand Down Expand Up @@ -159,6 +160,11 @@ fn main() -> Result<(), failure::Error> {

app.spotify = Some(spotify);

app.clipboard_context =
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could/should the clipboard_context be initialised in app.rs? Or is it easier to handle the error from main?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Problem is that currently app initialization cannot fail. If we make it failable we will have to adjust every test. That would touch almost every file, so I refrained from doing so

Some(clipboard::ClipboardProvider::new().map_err(|err| {
format_err!("failed to intialize clipboard context: {}", err)
})?);

// Now that spotify is ready, check if the user has already selected a device_id to
// play music on, if not send them to the device selection view
if app.client_config.device_id.is_none() {
Expand Down