Skip to content

Commit 35e0673

Browse files
if debug is used, also use the notificaition callback for the error
1 parent 23adc80 commit 35e0673

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

WDoc/WDoc.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,27 @@ def __init__(
135135
**cli_kwargs,
136136
) -> None:
137137
"This docstring is dynamically replaced by the content of WDoc/docs/USAGE.md"
138+
if notification_callback is not None:
139+
@optional_typecheck
140+
def ntfy(text: str) -> str:
141+
out = notification_callback(text)
142+
assert out == text, "The notification callback must return the same string"
143+
return out
144+
ntfy("Starting WDoc")
145+
else:
146+
@optional_typecheck
147+
def ntfy(text: str) -> str:
148+
return text
149+
self.ntfy = ntfy
150+
138151
if debug:
139152
def handle_exception(exc_type, exc_value, exc_traceback):
140153
if not issubclass(exc_type, KeyboardInterrupt):
141154
@optional_typecheck
142155
def p(message: str) -> None:
143156
"print error, in red if possible"
144157
try:
145-
red(message)
158+
red(self.ntfy(message))
146159
except Exception as err:
147160
print(message)
148161
p("\n--verbose was used so opening debug console at the "
@@ -376,19 +389,6 @@ def p(message: str) -> None:
376389
raise Exception(
377390
red(f"Can't find the price of {query_eval_modelname}"))
378391

379-
if notification_callback is not None:
380-
@optional_typecheck
381-
def ntfy(text: str) -> str:
382-
out = notification_callback(text)
383-
assert out == text, "The notification callback must return the same string"
384-
return out
385-
ntfy("Starting WDoc")
386-
else:
387-
@optional_typecheck
388-
def ntfy(text: str) -> str:
389-
return text
390-
self.ntfy = ntfy
391-
392392
if is_verbose:
393393
# os.environ["LANGCHAIN_TRACING_V2"] = "true"
394394
set_verbose(True)

0 commit comments

Comments
 (0)