From d57b40d0cc1f4ae6f949f58da1850375784bc368 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 30 Aug 2018 23:06:32 -0600 Subject: [PATCH] Clarify how the client should treat errors This is based on observation and rough interpretation and may need additional review from people. Fixes https://github.com/matrix-org/matrix-doc/issues/1188 --- specification/client_server_api.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/specification/client_server_api.rst b/specification/client_server_api.rst index cac83cfd6..489b8e0b7 100644 --- a/specification/client_server_api.rst +++ b/specification/client_server_api.rst @@ -100,7 +100,14 @@ custom namespace ``com.mydomain.here``, and a ``COM.MYDOMAIN.HERE_FORBIDDEN``. There may be additional keys depending on the error, but the keys ``error`` and ``errcode`` MUST always be present. -Some standard error codes are below: +Errors are generally best expressed by their error code rather than the HTTP +status code returned. When encountering the error code ``M_UNKNOWN``, clients +should prefer the HTTP status code as a more reliable reference for what the +issue was. For example, if the client receives an error code of ``M_NOT_FOUND`` +but the request gave a 400 Bad Request status code, the client should treat +the error as if the resource was not found. However, if the client were to +receive an error code of ``M_UNKNOWN`` with a 400 Bad Request, the client +should assume that the request being made was invalid. The common error codes are: