Skip to content

Commit f23e4e9

Browse files
committed
CONPY-205: Added error constants
Error code constants are now defined in constants/ERR. The file ERR.py is generated by helper/create_errconst.py script, please don't edit it.
1 parent 30c8f33 commit f23e4e9

File tree

5 files changed

+1262
-2
lines changed

5 files changed

+1262
-2
lines changed

helper/create_errconst.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import requests
2+
3+
ignore_definitions= ["ERR_ERROR_FIRST", "ER_ERROR_LAST", "CR_MIN_ERROR", "CR_MAX_ERROR",
4+
"CER_MIN_ERROR", "CER_MAX_ERROR", "CR_MYSQL_LAST_ERROR", "CR_MARIADB_LAST_ERROR"]
5+
6+
files= ["https://raw.githubusercontent.com/mariadb-corporation/mariadb-connector-c/3.3/include/mysqld_error.h",
7+
"https://raw.githubusercontent.com/mariadb-corporation/mariadb-connector-c/3.3/include/errmsg.h"]
8+
9+
error_definitions= []
10+
11+
for i in range(0, len(files)):
12+
errors= requests.get(files[i], allow_redirects=True)
13+
error_definitions+= errors.content.decode("utf8").split("\n")
14+
15+
print("# Autogenerated file. Please do not edit!\n\n")
16+
17+
for i in range(0, len(error_definitions)):
18+
x= error_definitions[i].split(" ")
19+
if len(x) == 3 and x[0] == "#define" and x[1] not in ignore_definitions and x[1][:9] != "ER_UNUSED":
20+
try:
21+
if int(x[2]) > 0:
22+
print("%s = %s" % (x[1], x[2]))
23+
except:
24+
pass

0 commit comments

Comments
 (0)