PlaylistFile: convert system_error::ENOENT to PlaylistResult::NO_SUCH_LIST
This commit is contained in:
parent
72851647ca
commit
fe0b6a1117
@ -55,6 +55,11 @@ public:
|
|||||||
"No such song");
|
"No such song");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PlaylistError NoSuchList() {
|
||||||
|
return PlaylistError(PlaylistResult::NO_SUCH_LIST,
|
||||||
|
"No such playlist");
|
||||||
|
}
|
||||||
|
|
||||||
static PlaylistError BadRange() {
|
static PlaylistError BadRange() {
|
||||||
return PlaylistError(PlaylistResult::BAD_RANGE,
|
return PlaylistError(PlaylistResult::BAD_RANGE,
|
||||||
"Bad song index");
|
"Bad song index");
|
||||||
|
@ -247,7 +247,7 @@ SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path,
|
|||||||
|
|
||||||
PlaylistFileContents
|
PlaylistFileContents
|
||||||
LoadPlaylistFile(const char *utf8path, Error &error)
|
LoadPlaylistFile(const char *utf8path, Error &error)
|
||||||
{
|
try {
|
||||||
PlaylistFileContents contents;
|
PlaylistFileContents contents;
|
||||||
|
|
||||||
const auto path_fs = spl_map_to_fs(utf8path, error);
|
const auto path_fs = spl_map_to_fs(utf8path, error);
|
||||||
@ -301,6 +301,10 @@ LoadPlaylistFile(const char *utf8path, Error &error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return contents;
|
return contents;
|
||||||
|
} catch (const std::system_error &e) {
|
||||||
|
if (IsFileNotFound(e))
|
||||||
|
throw PlaylistError::NoSuchList();
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -393,7 +397,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
spl_append_song(const char *utf8path, const DetachedSong &song, Error &error)
|
spl_append_song(const char *utf8path, const DetachedSong &song, Error &error)
|
||||||
{
|
try {
|
||||||
const auto path_fs = spl_map_to_fs(utf8path, error);
|
const auto path_fs = spl_map_to_fs(utf8path, error);
|
||||||
if (path_fs.IsNull())
|
if (path_fs.IsNull())
|
||||||
return false;
|
return false;
|
||||||
@ -415,6 +419,10 @@ spl_append_song(const char *utf8path, const DetachedSong &song, Error &error)
|
|||||||
|
|
||||||
idle_add(IDLE_STORED_PLAYLIST);
|
idle_add(IDLE_STORED_PLAYLIST);
|
||||||
return true;
|
return true;
|
||||||
|
} catch (const std::system_error &e) {
|
||||||
|
if (IsFileNotFound(e))
|
||||||
|
throw PlaylistError::NoSuchList();
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
Reference in New Issue
Block a user