diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index 5eefe1a..3008dd2 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -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; diff --git a/src/matrix-http-client.c b/src/matrix-http-client.c index 510860e..06dc2b2 100644 --- a/src/matrix-http-client.c +++ b/src/matrix-http-client.c @@ -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, diff --git a/src/matrix-types.c b/src/matrix-types.c index ed2e14c..1d43a0e 100644 --- a/src/matrix-types.c +++ b/src/matrix-types.c @@ -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 - * the request - * @MATRIX_ERROR_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 - * the homeserver - * @MATRIX_ERROR_NOT_JSON: illegal request, the content is not valid - * JSON - * @MATRIX_ERROR_UNRECOGNIZED: the homeserver didn't understand the - * request - * @MATRIX_ERROR_UNSPECIFIED: no error code was sent by the homeserver + * @MATRIX_ERROR_M_MISSING_TOKEN: authorization token is missing from + * the request + * @MATRIX_ERROR_M_FORBIDDEN: access was forbidden (e.g. due to a + * missing/invalid token, or using a bad + * password during login) + * @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_M_NOT_JSON: illegal request, the content is not valid + * JSON + * @MATRIX_ERROR_M_UNRECOGNIZED: the homeserver didn't understand the + * request + * @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 diff --git a/src/matrix-types.h b/src/matrix-types.h index 59123c3..43b6f65 100644 --- a/src/matrix-types.h +++ b/src/matrix-types.h @@ -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! */