Skip to content

Commit e02f66c

Browse files
committed
zstd: factor common parts of set_zstd_error()
1 parent 0c3c667 commit e02f66c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Modules/_zstd/_zstdmodule.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,44 @@ set_zstd_error(const _zstd_state* const state,
2828
switch (type)
2929
{
3030
case ERR_DECOMPRESS:
31-
msg = "Unable to decompress zstd data: %s";
31+
msg = "decompress zstd data";
3232
break;
3333
case ERR_COMPRESS:
34-
msg = "Unable to compress zstd data: %s";
34+
msg = "compress zstd data";
3535
break;
3636
case ERR_SET_PLEDGED_INPUT_SIZE:
37-
msg = "Unable to set pledged uncompressed content size: %s";
37+
msg = "set pledged uncompressed content size";
3838
break;
3939

4040
case ERR_LOAD_D_DICT:
41-
msg = "Unable to load zstd dictionary or prefix for decompression: %s";
41+
msg = "load zstd dictionary or prefix for decompression";
4242
break;
4343
case ERR_LOAD_C_DICT:
44-
msg = "Unable to load zstd dictionary or prefix for compression: %s";
44+
msg = "load zstd dictionary or prefix for compression";
4545
break;
4646

4747
case ERR_GET_C_BOUNDS:
48-
msg = "Unable to get zstd compression parameter bounds: %s";
48+
msg = "get zstd compression parameter bounds";
4949
break;
5050
case ERR_GET_D_BOUNDS:
51-
msg = "Unable to get zstd decompression parameter bounds: %s";
51+
msg = "get zstd decompression parameter bounds";
5252
break;
5353
case ERR_SET_C_LEVEL:
54-
msg = "Unable to set zstd compression level: %s";
54+
msg = "set zstd compression level";
5555
break;
5656

5757
case ERR_TRAIN_DICT:
58-
msg = "Unable to train zstd dictionary: %s";
58+
msg = "train zstd dictionary";
5959
break;
6060
case ERR_FINALIZE_DICT:
61-
msg = "Unable to finalize zstd dictionary: %s";
61+
msg = "finalize zstd dictionary";
6262
break;
6363

6464
default:
6565
Py_UNREACHABLE();
6666
}
67-
PyErr_Format(state->ZstdError, msg, ZSTD_getErrorName(zstd_ret));
67+
PyErr_Format(state->ZstdError, "Unable to %s: %s",
68+
msg, ZSTD_getErrorName(zstd_ret));
6869
}
6970

7071
typedef struct {

0 commit comments

Comments
 (0)