diff --git a/README.md b/README.md index de7d96d..de07fa8 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ def outer(): ### Save the exception traceback. -In the code, find the place where we need to do the `try ... except ...` and use `save_dumpling()`. When we save the dump file, it will default to `${exception filename}:${error lineno}.dump`. +In the code, find the place where we need to do the `try ... except ...` and use `save_dumpling()`. When we save the dump file, it will default to `${exception filename}-${error lineno}.dump`. ```python from pydumpling import save_dumping @@ -160,5 +160,25 @@ It will open the debugger on port 4444, then we can access pdb using telnet、ne `nc 127.0.0.1 4444` ![alt text](static/rpdb.png) +#### Enable global exception catching: +```python +from pydumpling import catch_any_exception + +catch_any_exception() + +def inner(): + a = 1 + b = "2" + c = a + b # noqa: F841 + + +def outer(): + inner() + +if __name__ == "__main__": + outer() + +``` + ## TODO - [] diff --git a/README_zh.md b/README_zh.md index 20bf178..060b193 100644 --- a/README_zh.md +++ b/README_zh.md @@ -48,7 +48,7 @@ def outer(): ### 在异常发生时进行异常堆栈的保存 -在异常捕获的处理代码中使用`save_dumpling()`. 如果不指定文件名,默认使用:`${exception file}:${line number of the exception}.dump`. +在异常捕获的处理代码中使用`save_dumpling()`. 如果不指定文件名,默认使用:`${exception file}-${line number of the exception}.dump`. ```python from pydumpling import save_dumping @@ -156,5 +156,25 @@ TypeError: unsupported operand type(s) for +: 'int' and 'str' `nc 127.0.0.1 4444` ![alt text](static/rpdb.png) +#### 开启全局异常捕获: +```python +from pydumpling import catch_any_exception + +catch_any_exception() + +def inner(): + a = 1 + b = "2" + c = a + b # noqa: F841 + + +def outer(): + inner() + +if __name__ == "__main__": + outer() + +``` + ## TODO - []