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

MPD error handling. More...

#include "dist/sds/sds.h"
#include "src/lib/api.h"
#include "src/lib/mympd_state.h"
Include dependency graph for errorhandler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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

◆ 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