10c16b537SWarner Losh /*
25ff13fbcSAllan Jude  * Copyright (c) Yann Collet, Facebook, Inc.
30c16b537SWarner Losh  * All rights reserved.
40c16b537SWarner Losh  *
50c16b537SWarner Losh  * This source code is licensed under both the BSD-style license (found in the
60c16b537SWarner Losh  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
70c16b537SWarner Losh  * in the COPYING file in the root directory of this source tree).
80c16b537SWarner Losh  * You may select, at your option, one of the above-listed licenses.
90c16b537SWarner Losh  */
100c16b537SWarner Losh 
110c16b537SWarner Losh /* The purpose of this file is to have a single list of error strings embedded in binary */
120c16b537SWarner Losh 
130c16b537SWarner Losh #include "error_private.h"
140c16b537SWarner Losh 
ERR_getErrorString(ERR_enum code)150c16b537SWarner Losh const char* ERR_getErrorString(ERR_enum code)
160c16b537SWarner Losh {
17a0483764SConrad Meyer #ifdef ZSTD_STRIP_ERROR_STRINGS
18a0483764SConrad Meyer     (void)code;
19a0483764SConrad Meyer     return "Error strings stripped";
20a0483764SConrad Meyer #else
210c16b537SWarner Losh     static const char* const notErrorCode = "Unspecified error code";
220c16b537SWarner Losh     switch( code )
230c16b537SWarner Losh     {
240c16b537SWarner Losh     case PREFIX(no_error): return "No error detected";
250c16b537SWarner Losh     case PREFIX(GENERIC):  return "Error (generic)";
260c16b537SWarner Losh     case PREFIX(prefix_unknown): return "Unknown frame descriptor";
270c16b537SWarner Losh     case PREFIX(version_unsupported): return "Version not supported";
280c16b537SWarner Losh     case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
290c16b537SWarner Losh     case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
300c16b537SWarner Losh     case PREFIX(corruption_detected): return "Corrupted block detected";
310c16b537SWarner Losh     case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
320c16b537SWarner Losh     case PREFIX(parameter_unsupported): return "Unsupported parameter";
330c16b537SWarner Losh     case PREFIX(parameter_outOfBound): return "Parameter is out of bound";
340c16b537SWarner Losh     case PREFIX(init_missing): return "Context should be init first";
350c16b537SWarner Losh     case PREFIX(memory_allocation): return "Allocation error : not enough memory";
3619fcbaf1SConrad Meyer     case PREFIX(workSpace_tooSmall): return "workSpace buffer is not large enough";
370c16b537SWarner Losh     case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
380c16b537SWarner Losh     case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
390c16b537SWarner Losh     case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
400c16b537SWarner Losh     case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
410c16b537SWarner Losh     case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
420c16b537SWarner Losh     case PREFIX(dictionary_wrong): return "Dictionary mismatch";
430c16b537SWarner Losh     case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
440c16b537SWarner Losh     case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
450c16b537SWarner Losh     case PREFIX(srcSize_wrong): return "Src size is incorrect";
46a0483764SConrad Meyer     case PREFIX(dstBuffer_null): return "Operation on NULL destination buffer";
470c16b537SWarner Losh         /* following error codes are not stable and may be removed or changed in a future version */
480c16b537SWarner Losh     case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
490c16b537SWarner Losh     case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
5037f1f268SConrad Meyer     case PREFIX(dstBuffer_wrong): return "Destination buffer is wrong";
51f7cd7fe5SConrad Meyer     case PREFIX(srcBuffer_wrong): return "Source buffer is wrong";
520c16b537SWarner Losh     case PREFIX(maxCode):
530c16b537SWarner Losh     default: return notErrorCode;
540c16b537SWarner Losh     }
55a0483764SConrad Meyer #endif
560c16b537SWarner Losh }
57