2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2011-09-11 07:51:27 +02:00
|
|
|
|
2013-08-10 19:40:45 +02:00
|
|
|
#ifndef MPD_PLAYLIST_ERROR_HXX
|
|
|
|
#define MPD_PLAYLIST_ERROR_HXX
|
2011-09-11 07:51:27 +02:00
|
|
|
|
2015-12-18 09:21:11 +01:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2013-08-10 18:02:44 +02:00
|
|
|
class Domain;
|
2011-09-11 07:41:25 +02:00
|
|
|
|
2013-10-19 19:50:54 +02:00
|
|
|
enum class PlaylistResult {
|
|
|
|
SUCCESS,
|
|
|
|
DENIED,
|
|
|
|
NO_SUCH_SONG,
|
|
|
|
NO_SUCH_LIST,
|
|
|
|
LIST_EXISTS,
|
|
|
|
BAD_NAME,
|
|
|
|
BAD_RANGE,
|
|
|
|
NOT_PLAYING,
|
|
|
|
TOO_LARGE,
|
|
|
|
DISABLED,
|
2011-09-11 07:51:27 +02:00
|
|
|
};
|
|
|
|
|
2013-08-10 18:02:44 +02:00
|
|
|
extern const Domain playlist_domain;
|
2011-09-11 07:41:25 +02:00
|
|
|
|
2015-12-18 09:21:11 +01:00
|
|
|
class PlaylistError : public std::runtime_error {
|
|
|
|
PlaylistResult code;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PlaylistError(PlaylistResult _code, const char *msg)
|
|
|
|
:std::runtime_error(msg), code(_code) {}
|
|
|
|
|
|
|
|
PlaylistResult GetCode() const {
|
|
|
|
return code;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PlaylistError NoSuchSong() {
|
2015-12-28 06:43:59 +01:00
|
|
|
return PlaylistError(PlaylistResult::NO_SUCH_SONG,
|
2015-12-18 09:21:11 +01:00
|
|
|
"No such song");
|
|
|
|
}
|
|
|
|
|
2015-12-28 06:43:41 +01:00
|
|
|
static PlaylistError NoSuchList() {
|
|
|
|
return PlaylistError(PlaylistResult::NO_SUCH_LIST,
|
|
|
|
"No such playlist");
|
|
|
|
}
|
|
|
|
|
2015-12-18 09:21:11 +01:00
|
|
|
static PlaylistError BadRange() {
|
|
|
|
return PlaylistError(PlaylistResult::BAD_RANGE,
|
|
|
|
"Bad song index");
|
|
|
|
}
|
2016-02-28 10:38:17 +01:00
|
|
|
|
|
|
|
static PlaylistError NotPlaying() {
|
|
|
|
return PlaylistError(PlaylistResult::NOT_PLAYING,
|
|
|
|
"Not playing");
|
|
|
|
}
|
2015-12-18 09:21:11 +01:00
|
|
|
};
|
|
|
|
|
2011-09-11 07:51:27 +02:00
|
|
|
#endif
|