1/* Copyright 2016 OpenMarket Ltd
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "olm/error.h"
17
18static const char * ERRORS[] = {
19 "SUCCESS",
20 "NOT_ENOUGH_RANDOM",
21 "OUTPUT_BUFFER_TOO_SMALL",
22 "BAD_MESSAGE_VERSION",
23 "BAD_MESSAGE_FORMAT",
24 "BAD_MESSAGE_MAC",
25 "BAD_MESSAGE_KEY_ID",
26 "INVALID_BASE64",
27 "BAD_ACCOUNT_KEY",
28 "UNKNOWN_PICKLE_VERSION",
29 "CORRUPTED_PICKLE",
30 "BAD_SESSION_KEY",
31 "UNKNOWN_MESSAGE_INDEX",
32 "BAD_LEGACY_ACCOUNT_PICKLE",
33 "BAD_SIGNATURE",
34 "OLM_INPUT_BUFFER_TOO_SMALL",
35 "OLM_SAS_THEIR_KEY_NOT_SET",
36 "OLM_PICKLE_EXTRA_DATA"
37};
38
39const char * _olm_error_to_string(enum OlmErrorCode error)
40{
41 if (error < (sizeof(ERRORS)/sizeof(ERRORS[0]))) {
42 return ERRORS[error];
43 } else {
44 return "UNKNOWN_ERROR";
45 }
46}
47