@@ -37,6 +37,20 @@ private async void AddLyricsButton_Click(object sender, RoutedEventArgs e)
3737 await EditLyrics ( true ) ;
3838 }
3939
40+ private async void DisplayError ( IOException ex )
41+ {
42+ ContentDialog dialog = new ContentDialog ( ) ;
43+
44+ dialog . XamlRoot = XamlRoot ;
45+ dialog . Title = "An error has occurred." ;
46+ dialog . CloseButtonText = "Sad" ;
47+ dialog . DefaultButton = ContentDialogButton . Close ;
48+ dialog . Content = new LyricErrorPopup ( ) ;
49+ LyricErrorPopup content = ( LyricErrorPopup ) dialog . Content ;
50+ content . SetText ( ex . Message ) ;
51+
52+ await dialog . ShowAsync ( ) ;
53+ }
4054 private async Task EditLyrics ( bool adding = false )
4155 {
4256 if ( Audio . CurrentSongPlaying == null ) return ;
@@ -100,8 +114,14 @@ private async Task EditLyrics(bool adding = false)
100114 if ( Audio . CurrentSongPlaying == null ) return ;
101115 if ( dialog . Content is AddLyricsPopup popup )
102116 {
103- Audio . CurrentSongPlaying . Lyrics = lyrics ;
104- if ( ! popup . SessionChecked ) await Audio . CurrentSongPlaying . ApplyLyricsToFileAsync ( ) ;
117+ if ( ! popup . SessionChecked )
118+ {
119+ var ex = Audio . CurrentSongPlaying . AttemptApplyLyricsToFile ( lyrics ) ;
120+ if ( ex != null ) DisplayError ( ex ) ;
121+ } else
122+ {
123+ Audio . CurrentSongPlaying . Lyrics = lyrics ;
124+ }
105125 }
106126 break ;
107127 case ContentDialogResult . Secondary :
@@ -139,30 +159,37 @@ private async Task EditLyrics(bool adding = false)
139159 {
140160 if ( Audio . CurrentSongPlaying == null ) return ;
141161 var text = await package . GetTextAsync ( ) ;
142- Audio . CurrentSongPlaying . Lyrics = text ;
143162 if ( dialog . Content is AddLyricsPopup popup )
144163 {
145- if ( ! popup . SessionChecked ) await Audio . CurrentSongPlaying . ApplyLyricsToFileAsync ( ) ;
164+ if ( ! popup . SessionChecked )
165+ {
166+ var ex = Audio . CurrentSongPlaying . AttemptApplyLyricsToFile ( text ) ;
167+ if ( ex != null ) DisplayError ( ex ) ;
168+ }
169+ else
170+ {
171+ Audio . CurrentSongPlaying . Lyrics = text ;
172+ } ;
146173 }
147174 }
148175 break ;
149176 default :
150177 break ;
151178 }
152179 }
153- private async void ClearLyrics ( )
180+ private void ClearLyrics ( )
154181 {
155182 Song currentSong = Audio . CurrentSongPlaying ;
156183 if ( currentSong == null ) return ;
157- currentSong . Lyrics = "" ;
158- await currentSong . ApplyLyricsToFileAsync ( ) ;
184+ var ex = currentSong . AttemptApplyLyricsToFile ( "" ) ;
185+ if ( ex != null ) DisplayError ( ex ) ;
159186 }
160- private async void MarkAsInstrumental ( )
187+ private void MarkAsInstrumental ( )
161188 {
162189 Song currentSong = Audio . CurrentSongPlaying ;
163190 if ( currentSong == null ) return ;
164- currentSong . Lyrics = "[INSTRUMENTAL]" ;
165- await currentSong . ApplyLyricsToFileAsync ( ) ;
191+ var ex = currentSong . AttemptApplyLyricsToFile ( "[INSTRUMENTAL]" ) ;
192+ if ( ex != null ) DisplayError ( ex ) ;
166193 }
167194 private void MarkInstrumentalButton_Click ( object sender , RoutedEventArgs e )
168195 {
0 commit comments