Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
0f4f04ea
Commit
0f4f04ea
authored
Nov 11, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/CommandError: send verbose error message to client
parent
2e55d561
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
22 deletions
+56
-22
NEWS
NEWS
+1
-0
CommandError.cxx
src/command/CommandError.cxx
+55
-22
No files found.
NEWS
View file @
0f4f04ea
...
...
@@ -6,6 +6,7 @@ ver 0.20 (not yet released)
- "sticker find" can match sticker values
- drop the "file:///" prefix for absolute file paths
- add range parameter to command "plchanges" and "plchangesposid"
- send verbose error message to client
* tags
- ape, ogg: drop support for non-standard tag "album artist"
affected filetypes: vorbis, flac, opus & all files with ape2 tags
...
...
src/command/CommandError.cxx
View file @
0f4f04ea
...
...
@@ -29,6 +29,41 @@
#include <string.h>
#include <errno.h>
gcc_const
static
enum
ack
ToAck
(
PlaylistResult
result
)
{
switch
(
result
)
{
case
PlaylistResult
:
:
SUCCESS
:
break
;
case
PlaylistResult
:
:
DENIED
:
return
ACK_ERROR_PERMISSION
;
case
PlaylistResult
:
:
NO_SUCH_SONG
:
case
PlaylistResult
:
:
NO_SUCH_LIST
:
return
ACK_ERROR_NO_EXIST
;
case
PlaylistResult
:
:
LIST_EXISTS
:
return
ACK_ERROR_EXIST
;
case
PlaylistResult
:
:
BAD_NAME
:
case
PlaylistResult
:
:
BAD_RANGE
:
return
ACK_ERROR_ARG
;
case
PlaylistResult
:
:
NOT_PLAYING
:
return
ACK_ERROR_PLAYER_SYNC
;
case
PlaylistResult
:
:
TOO_LARGE
:
return
ACK_ERROR_PLAYLIST_MAX
;
case
PlaylistResult
:
:
DISABLED
:
break
;
}
return
ACK_ERROR_UNKNOWN
;
}
CommandResult
print_playlist_result
(
Response
&
r
,
PlaylistResult
result
)
{
...
...
@@ -82,43 +117,41 @@ print_playlist_result(Response &r, PlaylistResult result)
return
CommandResult
::
ERROR
;
}
CommandResult
print_error
(
Response
&
r
,
const
Error
&
error
)
gcc_pure
static
enum
ack
ToAck
(
const
Error
&
error
)
{
assert
(
error
.
IsDefined
());
LogError
(
error
);
if
(
error
.
IsDomain
(
playlist_domain
))
{
return
print_playlist_result
(
r
,
PlaylistResult
(
error
.
GetCode
()));
return
ToAck
((
PlaylistResult
)
error
.
GetCode
());
}
else
if
(
error
.
IsDomain
(
ack_domain
))
{
r
.
Error
((
ack
)
error
.
GetCode
(),
error
.
GetMessage
());
return
CommandResult
::
ERROR
;
return
(
enum
ack
)
error
.
GetCode
();
#ifdef ENABLE_DATABASE
}
else
if
(
error
.
IsDomain
(
db_domain
))
{
switch
((
enum
db_error
)
error
.
GetCode
())
{
case
DB_DISABLED
:
r
.
Error
(
ACK_ERROR_NO_EXIST
,
error
.
GetMessage
());
return
CommandResult
::
ERROR
;
case
DB_NOT_FOUND
:
r
.
Error
(
ACK_ERROR_NO_EXIST
,
"Not found"
);
return
CommandResult
::
ERROR
;
return
ACK_ERROR_NO_EXIST
;
case
DB_CONFLICT
:
r
.
Error
(
ACK_ERROR_ARG
,
"Conflict"
);
return
CommandResult
::
ERROR
;
return
ACK_ERROR_ARG
;
}
#endif
}
else
if
(
error
.
IsDomain
(
locate_uri_domain
))
{
r
.
Error
(
ACK_ERROR_ARG
,
error
.
GetMessage
());
return
CommandResult
::
ERROR
;
return
ACK_ERROR_ARG
;
}
else
if
(
error
.
IsDomain
(
errno_domain
))
{
r
.
Error
(
ACK_ERROR_SYSTEM
,
strerror
(
error
.
GetCode
()));
return
CommandResult
::
ERROR
;
return
ACK_ERROR_SYSTEM
;
}
r
.
Error
(
ACK_ERROR_UNKNOWN
,
"error"
);
return
ACK_ERROR_UNKNOWN
;
}
CommandResult
print_error
(
Response
&
r
,
const
Error
&
error
)
{
assert
(
error
.
IsDefined
());
LogError
(
error
);
r
.
Error
(
ToAck
(
error
),
error
.
GetMessage
());
return
CommandResult
::
ERROR
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment