myMPD
Internal API documentation
Loading...
Searching...
No Matches
errorhandler.c File Reference

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>
Include dependency graph for errorhandler.c:

Functions

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)
 

Detailed Description

MPD error handling.

Function Documentation

◆ check_error_and_recover()

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 
)
static

Private definitions

Private functions Calls mpd_response_finish and checks for an mpd error and tries to recover.

Parameters
partition_statepointer to partition specific states
bufferalready allocated sds string for the jsonrpc response or NULL
cmd_idenum mympd_cmd_ids
request_idjsonrpc request id to respond
response_typeresponse message type
commandcommand 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_statepointer to partition specific states
errorpointer to an already allocated sds string for the error message or NULL
commandlast 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_statepointer to partition specific states
bufferalready allocated sds string for the jsonrpc response or NULL
commandlast 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_statepointer to partition specific states
bufferalready allocated sds string for the mpd error message or NULL
commandlast 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_statepointer to partition specific states
bufferpointer to an already allocated sds string for the jsonrpc response or NULL
cmd_idenum mympd_cmd_ids
request_idjsonrpc request id to respond
commandlast mpd command
Returns
true on success, else false

◆ mympd_clear_finish()

bool mympd_clear_finish ( struct t_partition_state partition_state)

Silently clears a recoverable MPD error

Parameters
partition_statePointer 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_statepointer to partition specific states
bufferalready allocated sds string for the jsonrpc response or NULL
cmd_idenum mympd_cmd_ids
request_idjsonrpc request id to respond
commandlast mpd command
resultpointer 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_statePointer to partition state
errormessageError message to log