refactor: Improved error handling project-wide and cleaned up some regexes with unnecessary escapes (tail_logs and interpolate_env_vars)
This commit is contained in:
@@ -80,14 +80,14 @@ fn draw_add_series_search(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.add_series_search
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("add_series_search must be populated")
|
||||
.text;
|
||||
let offset = app
|
||||
.data
|
||||
.sonarr_data
|
||||
.add_series_search
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("add_series_search must be populated")
|
||||
.offset
|
||||
.load(Ordering::SeqCst);
|
||||
let search_results_row_mapping = |series: &AddSeriesSearchResult| {
|
||||
@@ -232,7 +232,7 @@ fn draw_confirmation_prompt(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.add_searched_series
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("add_searched_series must be populated")
|
||||
.current_selection()
|
||||
.title
|
||||
.text,
|
||||
@@ -241,7 +241,7 @@ fn draw_confirmation_prompt(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.add_searched_series
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("add_searched_series must be populated")
|
||||
.current_selection()
|
||||
.overview
|
||||
.clone()
|
||||
@@ -261,7 +261,12 @@ fn draw_confirmation_prompt(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
use_season_folder,
|
||||
tags,
|
||||
..
|
||||
} = app.data.sonarr_data.add_series_modal.as_ref().unwrap();
|
||||
} = app
|
||||
.data
|
||||
.sonarr_data
|
||||
.add_series_modal
|
||||
.as_ref()
|
||||
.expect("add_series_modal must exist in this context");
|
||||
|
||||
let selected_monitor = monitor_list.current_selection();
|
||||
let selected_series_type = series_type_list.current_selection();
|
||||
@@ -367,7 +372,7 @@ fn draw_add_series_select_monitor_popup(f: &mut Frame<'_>, app: &mut App<'_>) {
|
||||
.sonarr_data
|
||||
.add_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("add_series_modal must exist in this context")
|
||||
.monitor_list,
|
||||
|monitor| ListItem::new(monitor.to_display_str().to_owned()),
|
||||
);
|
||||
@@ -383,7 +388,7 @@ fn draw_add_series_select_series_type_popup(f: &mut Frame<'_>, app: &mut App<'_>
|
||||
.sonarr_data
|
||||
.add_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("add_series_modal must exist in this context")
|
||||
.series_type_list,
|
||||
|series_type| ListItem::new(series_type.to_display_str().to_owned()),
|
||||
);
|
||||
@@ -399,7 +404,7 @@ fn draw_add_series_select_quality_profile_popup(f: &mut Frame<'_>, app: &mut App
|
||||
.sonarr_data
|
||||
.add_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("add_series_modal must exist in this context")
|
||||
.quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
@@ -415,7 +420,7 @@ fn draw_add_series_select_language_profile_popup(f: &mut Frame<'_>, app: &mut Ap
|
||||
.sonarr_data
|
||||
.add_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("add_series_modal must exist in this context")
|
||||
.language_profile_list,
|
||||
|language_profile| ListItem::new(language_profile.clone()),
|
||||
);
|
||||
@@ -431,7 +436,7 @@ fn draw_add_series_select_root_folder_popup(f: &mut Frame<'_>, app: &mut App<'_>
|
||||
.sonarr_data
|
||||
.add_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("add_series_modal must exist in this context")
|
||||
.root_folder_list,
|
||||
|root_folder| ListItem::new(root_folder.path.to_owned()),
|
||||
);
|
||||
|
||||
@@ -99,7 +99,12 @@ fn draw_edit_series_confirmation_prompt(f: &mut Frame<'_>, app: &mut App<'_>, ar
|
||||
use_season_folders,
|
||||
path,
|
||||
tags,
|
||||
} = app.data.sonarr_data.edit_series_modal.as_ref().unwrap();
|
||||
} = app
|
||||
.data
|
||||
.sonarr_data
|
||||
.edit_series_modal
|
||||
.as_ref()
|
||||
.expect("edit_series_modal must exist in this context");
|
||||
let selected_series_type = series_type_list.current_selection();
|
||||
let selected_quality_profile = quality_profile_list.current_selection();
|
||||
let selected_language_profile = language_profile_list.current_selection();
|
||||
@@ -202,7 +207,7 @@ fn draw_edit_series_select_series_type_popup(f: &mut Frame<'_>, app: &mut App<'_
|
||||
.sonarr_data
|
||||
.edit_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("edit_series_modal must exist in this context")
|
||||
.series_type_list,
|
||||
|series_type| ListItem::new(series_type.to_display_str().to_owned()),
|
||||
);
|
||||
@@ -218,7 +223,7 @@ fn draw_edit_series_select_quality_profile_popup(f: &mut Frame<'_>, app: &mut Ap
|
||||
.sonarr_data
|
||||
.edit_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("edit_series_modal must exist in this context")
|
||||
.quality_profile_list,
|
||||
|quality_profile| ListItem::new(quality_profile.clone()),
|
||||
);
|
||||
@@ -234,7 +239,7 @@ fn draw_edit_series_select_language_profile_popup(f: &mut Frame<'_>, app: &mut A
|
||||
.sonarr_data
|
||||
.edit_series_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("edit_series_modal must exist in this context")
|
||||
.language_profile_list,
|
||||
|language_profile| ListItem::new(language_profile.clone()),
|
||||
);
|
||||
|
||||
@@ -60,10 +60,10 @@ impl DrawUi for EpisodeDetailsUi {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("episode_details_modal must exist in this context")
|
||||
.episode_details_tabs,
|
||||
);
|
||||
draw_episode_details_tabs(f, app, content_area);
|
||||
@@ -77,7 +77,7 @@ impl DrawUi for EpisodeDetailsUi {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episodes
|
||||
.current_selection()
|
||||
.title
|
||||
@@ -181,7 +181,7 @@ fn draw_episode_details(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.is_none(),
|
||||
block,
|
||||
@@ -303,10 +303,10 @@ fn draw_episode_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect)
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("episode_details_modal must exist in this context")
|
||||
.episode_history;
|
||||
let history_table =
|
||||
ManagarrTable::new(Some(&mut episode_history_table), history_row_mapping)
|
||||
@@ -332,7 +332,7 @@ fn draw_episode_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect)
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.is_none(),
|
||||
layout_block_top_border(),
|
||||
@@ -474,10 +474,10 @@ fn draw_episode_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("episode_details_modal must exist in this context")
|
||||
.episode_releases;
|
||||
let release_table = ManagarrTable::new(
|
||||
Some(&mut episode_release_table),
|
||||
@@ -513,7 +513,7 @@ fn draw_episode_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.is_none(),
|
||||
layout_block_top_border(),
|
||||
@@ -529,10 +529,10 @@ fn draw_manual_episode_search_confirm_prompt(f: &mut Frame<'_>, app: &mut App<'_
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episode_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("episode_details_modal must exist in this context")
|
||||
.episode_releases
|
||||
.current_selection();
|
||||
let title = if current_selection.rejected {
|
||||
|
||||
@@ -106,11 +106,11 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.map_or(0f64, |stats| convert_to_gb(stats.size_on_disk));
|
||||
let quality_profile = quality_profile_map
|
||||
.get_by_left(&series.quality_profile_id)
|
||||
.unwrap()
|
||||
.expect("Quality profile ID must exist in quality_profile_map")
|
||||
.to_owned();
|
||||
let language_profile = language_profile_map
|
||||
.get_by_left(&series.language_profile_id)
|
||||
.unwrap()
|
||||
.expect("Language profile ID must exist in language_profile_map")
|
||||
.to_owned();
|
||||
let empty_tag = String::new();
|
||||
let tags = if !series.tags.is_empty() {
|
||||
@@ -119,7 +119,7 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.iter()
|
||||
.map(|tag_id| {
|
||||
tags_map
|
||||
.get_by_left(&tag_id.as_i64().unwrap())
|
||||
.get_by_left(&tag_id.as_i64().expect("Tag ID must be a valid i64"))
|
||||
.unwrap_or(&empty_tag)
|
||||
.clone()
|
||||
})
|
||||
|
||||
@@ -67,7 +67,7 @@ impl DrawUi for SeasonDetailsUi {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.season_details_tabs,
|
||||
);
|
||||
draw_season_details(f, app, content_area);
|
||||
@@ -103,7 +103,7 @@ impl DrawUi for SeasonDetailsUi {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.episodes
|
||||
.current_selection()
|
||||
.title
|
||||
@@ -294,7 +294,7 @@ fn draw_season_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.season_history;
|
||||
let history_table =
|
||||
ManagarrTable::new(Some(&mut season_history_table), history_row_mapping)
|
||||
@@ -426,7 +426,7 @@ fn draw_season_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.season_releases;
|
||||
let release_table =
|
||||
ManagarrTable::new(Some(&mut season_release_table), season_release_row_mapping)
|
||||
@@ -467,7 +467,7 @@ fn draw_manual_season_search_confirm_prompt(f: &mut Frame<'_>, app: &mut App<'_>
|
||||
.sonarr_data
|
||||
.season_details_modal
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.expect("season_details_modal must exist in this context")
|
||||
.season_releases
|
||||
.current_selection();
|
||||
let title = if current_selection.rejected {
|
||||
|
||||
@@ -333,7 +333,12 @@ fn draw_series_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
||||
])
|
||||
.primary()
|
||||
};
|
||||
let mut series_history_table = app.data.sonarr_data.series_history.as_mut().unwrap();
|
||||
let mut series_history_table = app
|
||||
.data
|
||||
.sonarr_data
|
||||
.series_history
|
||||
.as_mut()
|
||||
.expect("series_history must be populated");
|
||||
let history_table =
|
||||
ManagarrTable::new(Some(&mut series_history_table), history_row_mapping)
|
||||
.block(layout_block_top_border())
|
||||
|
||||
Reference in New Issue
Block a user