MPD error handling.
More...
#include "compile_time.h"
#include "src/mympd_client/errorhandler.h"
#include "src/lib/json/json_rpc.h"
#include "src/lib/log.h"
#include "src/lib/timer.h"
#include "src/mympd_client/connection.h"
#include "src/mympd_client/tags.h"
#include <assert.h>
#include <string.h>
|
| static bool | check_error_and_recover (struct t_partition_state *partition_state, sds *buffer, enum mympd_cmd_ids cmd_id, unsigned request_id, enum jsonrpc_response_types response_type, const char *command) |
| |
| void | mympd_set_mpd_failure (struct t_partition_state *partition_state, const char *errormessage) |
| |
| bool | mympd_check_error_and_recover (struct t_partition_state *partition_state, sds *error, const char *command) |
| |
| bool | mympd_check_error_and_recover_respond (struct t_partition_state *partition_state, sds *buffer, enum mympd_cmd_ids cmd_id, unsigned request_id, const char *command) |
| |
| bool | mympd_check_error_and_recover_notify (struct t_partition_state *partition_state, sds *buffer, const char *command) |
| |
| bool | mympd_check_error_and_recover_plain (struct t_partition_state *partition_state, sds *buffer, const char *command) |
| |
| sds | mympd_respond_with_error_or_ok (struct t_partition_state *partition_state, sds buffer, enum mympd_cmd_ids cmd_id, unsigned request_id, const char *command, bool *result) |
| |
| bool | mympd_clear_finish (struct t_partition_state *partition_state) |
| |
◆ check_error_and_recover()
Private definitions
Private functions Calls mpd_response_finish and checks for an mpd error and tries to recover.
- Parameters
-
| partition_state | pointer to partition specific states |
| buffer | already allocated sds string for the jsonrpc response or NULL |
| cmd_id | enum mympd_cmd_ids |
| request_id | jsonrpc request id to respond |
| response_type | response message type |
| command | command to check for the error |
- Returns
- true on success, else false
◆ mympd_check_error_and_recover()
| bool mympd_check_error_and_recover |
( |
struct t_partition_state * |
partition_state, |
|
|
sds * |
error, |
|
|
const char * |
command |
|
) |
| |
Checks for mpd protocol error and tries to recover it
- Parameters
-
| partition_state | pointer to partition specific states |
| error | pointer to an already allocated sds string for the error message or NULL |
| command | last mpd command |
- Returns
- true on success, else false
◆ mympd_check_error_and_recover_notify()
| bool mympd_check_error_and_recover_notify |
( |
struct t_partition_state * |
partition_state, |
|
|
sds * |
buffer, |
|
|
const char * |
command |
|
) |
| |
Checks for mpd protocol error and tries to recover it. Creates a jsonrpc notification on error.
- Parameters
-
| partition_state | pointer to partition specific states |
| buffer | already allocated sds string for the jsonrpc response or NULL |
| command | last mpd command |
- Returns
- true on success, else false
◆ mympd_check_error_and_recover_plain()
| bool mympd_check_error_and_recover_plain |
( |
struct t_partition_state * |
partition_state, |
|
|
sds * |
buffer, |
|
|
const char * |
command |
|
) |
| |
Checks for mpd protocol error and tries to recover it. Returns the plain mpd error message.
- Parameters
-
| partition_state | pointer to partition specific states |
| buffer | already allocated sds string for the mpd error message or NULL |
| command | last mpd command |
- Returns
- true on success, else false
◆ mympd_check_error_and_recover_respond()
| bool mympd_check_error_and_recover_respond |
( |
struct t_partition_state * |
partition_state, |
|
|
sds * |
buffer, |
|
|
enum mympd_cmd_ids |
cmd_id, |
|
|
unsigned |
request_id, |
|
|
const char * |
command |
|
) |
| |
Checks for mpd protocol error and tries to recover it. Creates a jsonrpc response on error.
- Parameters
-
| partition_state | pointer to partition specific states |
| buffer | pointer to an already allocated sds string for the jsonrpc response or NULL |
| cmd_id | enum mympd_cmd_ids |
| request_id | jsonrpc request id to respond |
| command | last mpd command |
- Returns
- true on success, else false
◆ mympd_clear_finish()
Silently clears a recoverable MPD error
- Parameters
-
| partition_state | Pointer to partition state |
- Returns
- true on success, else false
◆ mympd_respond_with_error_or_ok()
| sds mympd_respond_with_error_or_ok |
( |
struct t_partition_state * |
partition_state, |
|
|
sds |
buffer, |
|
|
enum mympd_cmd_ids |
cmd_id, |
|
|
unsigned |
request_id, |
|
|
const char * |
command, |
|
|
bool * |
result |
|
) |
| |
Checks for mpd protocol error and return code of last mpd command and tries to recover it. Creates always a jsonrpc response. Shortcut for mympd_check_rc_error_and_recover and jsonrpc_respond_ok
- Parameters
-
| partition_state | pointer to partition specific states |
| buffer | already allocated sds string for the jsonrpc response or NULL |
| cmd_id | enum mympd_cmd_ids |
| request_id | jsonrpc request id to respond |
| command | last mpd command |
| result | pointer to bool for result code |
- Returns
- pointer to buffer
◆ mympd_set_mpd_failure()
| void mympd_set_mpd_failure |
( |
struct t_partition_state * |
partition_state, |
|
|
const char * |
errormessage |
|
) |
| |
Public functions Sets the MPD_FAILURE state for the partition. myMPD disconnects and tries a reconnect.
- Parameters
-
| partition_state | Pointer to partition state |
| errormessage | Error message to log |