Sanitize M_ error codes
This commit is contained in:
parent
bf32466112
commit
9f87e8b646
@ -637,7 +637,7 @@ _response_callback(SoupSession *session,
|
||||
|
||||
if (strncmp("M_", errcode, 2) == 0) {
|
||||
gchar *matrix_error_code = g_strdup_printf(
|
||||
"MATRIX_ERROR_%s", errcode + 2);
|
||||
"MATRIX_ERROR_%s", errcode);
|
||||
|
||||
error_class = g_type_class_ref(
|
||||
MATRIX_TYPE_ERROR);
|
||||
@ -2314,7 +2314,7 @@ i_token_refresh(MatrixAPI *api,
|
||||
|
||||
if (!refresh_token && !priv->refresh_token) {
|
||||
g_set_error(error,
|
||||
MATRIX_ERROR, MATRIX_ERROR_MISSING_TOKEN,
|
||||
MATRIX_ERROR, MATRIX_ERROR_M_MISSING_TOKEN,
|
||||
"No token available");
|
||||
|
||||
return;
|
||||
|
@ -166,7 +166,7 @@ cb_event_stream(MatrixAPI *api,
|
||||
// Only continue polling if polling is still enabled, and there
|
||||
// was no communication error during the last call
|
||||
if (priv->polling
|
||||
&& (!error || error->code <= MATRIX_ERROR_MISSING_TOKEN)) {
|
||||
&& (!error || error->code <= MATRIX_ERROR_M_MISSING_TOKEN)) {
|
||||
priv->polling = FALSE;
|
||||
|
||||
matrix_api_event_stream(api,
|
||||
|
@ -45,19 +45,21 @@
|
||||
* server contains a value unknown to
|
||||
* this library. These should be reported
|
||||
* to the Matrix GLib SDK developers
|
||||
* @MATRIX_ERROR_MISSING_TOKEN: authorization token is missing from
|
||||
* @MATRIX_ERROR_M_MISSING_TOKEN: authorization token is missing from
|
||||
* the request
|
||||
* @MATRIX_ERROR_FORBIDDEN: access was forbidden (e.g. due to a
|
||||
* @MATRIX_ERROR_M_FORBIDDEN: access was forbidden (e.g. due to a
|
||||
* missing/invalid token, or using a bad
|
||||
* password during login)
|
||||
* @MATRIX_ERROR_UNKNOWN: an error unknown to the Matrix homeserver
|
||||
* @MATRIX_ERROR_UNKNOWN_TOKEN: the token provided is not known for
|
||||
* @MATRIX_ERROR_M_UNKNOWN: an error unknown to the Matrix homeserver
|
||||
* @MATRIX_ERROR_M_UNKNOWN_TOKEN: the token provided is not known for
|
||||
* the homeserver
|
||||
* @MATRIX_ERROR_NOT_JSON: illegal request, the content is not valid
|
||||
* @MATRIX_ERROR_M_NOT_JSON: illegal request, the content is not valid
|
||||
* JSON
|
||||
* @MATRIX_ERROR_UNRECOGNIZED: the homeserver didn't understand the
|
||||
* @MATRIX_ERROR_M_UNRECOGNIZED: the homeserver didn't understand the
|
||||
* request
|
||||
* @MATRIX_ERROR_UNSPECIFIED: no error code was sent by the homeserver
|
||||
* @MATRIX_ERROR_UNSPECIFIED: no error code was sent by the
|
||||
* homeserver. If you see this error, that
|
||||
* usually indicates a homeserver bug
|
||||
* @MATRIX_ERROR_UNKNOWN_ERROR: an error unknown to this library
|
||||
*
|
||||
* Value mappings from Matrix.org API error codes
|
||||
|
@ -33,15 +33,15 @@ typedef enum {
|
||||
MATRIX_ERROR_INVALID_ROOM_ID,
|
||||
MATRIX_ERROR_UNKNOWN_VALUE,
|
||||
|
||||
/* Add Matrix-defined error codes under here, changing `M_` to
|
||||
* `MATRIX_ERROR`, i.e. `M_FORBIDDEN` =>
|
||||
* `MATRIX_ERROR_FORBIDDEN` */
|
||||
MATRIX_ERROR_MISSING_TOKEN = 500,
|
||||
MATRIX_ERROR_FORBIDDEN,
|
||||
MATRIX_ERROR_UNKNOWN,
|
||||
MATRIX_ERROR_UNKNOWN_TOKEN,
|
||||
MATRIX_ERROR_NOT_JSON,
|
||||
MATRIX_ERROR_UNRECOGNIZED,
|
||||
/* Add Matrix-defined error codes under here, prefixing them with
|
||||
* `MATRIX_ERROR_`, i.e. `M_FORBIDDEN` =>
|
||||
* `MATRIX_ERROR_M_FORBIDDEN` */
|
||||
MATRIX_ERROR_M_MISSING_TOKEN = 500,
|
||||
MATRIX_ERROR_M_FORBIDDEN,
|
||||
MATRIX_ERROR_M_UNKNOWN,
|
||||
MATRIX_ERROR_M_UNKNOWN_TOKEN,
|
||||
MATRIX_ERROR_M_NOT_JSON,
|
||||
MATRIX_ERROR_M_UNRECOGNIZED,
|
||||
|
||||
/* Allow for a lot of Matrix.org defined codes
|
||||
Do not define error codes after this! */
|
||||
|
Loading…
Reference in New Issue
Block a user