Skip to content

Commit fb836aa

Browse files
committed
add show_edge_case_warning() func
1 parent d929fd9 commit fb836aa

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

dokuWikiDumper/exceptions.py

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import os
2+
import sys
3+
import traceback
4+
5+
from dokuWikiDumper.__version__ import DUMPER_VERSION
6+
7+
18
class VersionOutdatedError(Exception):
29
def __init__(self, version):
310
self.version = version
@@ -84,3 +91,22 @@ def __str__(self):
8491
return "Revision list not found for [[%s]]" % self.title
8592

8693

94+
def show_edge_case_warning(**context):
95+
if int(os.environ.get('EDGECASE_OK', '0')):
96+
return
97+
98+
print(
99+
"[WARNING]\n"
100+
"--------------------------------------------\n"
101+
"The program is about to enter an edge case code, "
102+
"which lacks real world testing, I'm not sure if the code that runs next can handle it properly. "
103+
"So I hope you could paste the following details to <https://github.com/saveweb/dokuwiki-dumper/discussions> "
104+
"to help me improve the code, Thanks!")
105+
print("------------------------------------------")
106+
calledfrom = traceback.extract_stack(limit=2)[0]
107+
print("VERSION:", DUMPER_VERSION)
108+
print("FUNC:", f'{calledfrom.filename}:{calledfrom.lineno} ', "FUNC:", calledfrom.name)
109+
print("CONTEXT:", context)
110+
print("------------------------------------------")
111+
print("To continue executing the edge case code, re-run with --edgecase-ok")
112+
sys.exit(13)

0 commit comments

Comments
 (0)