Debug catch exception
parent
2f12cbd175
commit
21182483dc
46
debug.md
46
debug.md
|
@ -107,6 +107,50 @@ def call_mri()
|
|||
|
||||
![image](uploads/7c02ea9b4c944439af4a149e3c71d499/image.png)
|
||||
|
||||
|
||||
<BR>
|
||||
|
||||
## Catch exceptions
|
||||
|
||||
* In generally, LibreOffice try show you any error.
|
||||
|
||||
```python
|
||||
def error1():
|
||||
if True:
|
||||
app.msgbox('This not work')
|
||||
return
|
||||
```
|
||||
|
||||
```python
|
||||
def error2():
|
||||
r = 1 / 0
|
||||
return
|
||||
```
|
||||
|
||||
* Sometimes, for difficult errors, you can used.
|
||||
|
||||
```python
|
||||
@app.catch_exception
|
||||
def test():
|
||||
r = 1 / 0
|
||||
return
|
||||
```
|
||||
|
||||
* Show in shell
|
||||
|
||||
```
|
||||
29/09/2019 21:50:51 - ERROR - test
|
||||
Traceback (most recent call last):
|
||||
File "/home/mau/.config/libreoffice/4/user/Scripts/python/pythonpath/easymacro.py", line 231, in func
|
||||
return f(*args, **kwargs)
|
||||
File "/home/mau/.config/libreoffice/4/user/Scripts/python/mymacros.py", line 12, in test
|
||||
r = 1 / 0
|
||||
ZeroDivisionError: division by zero
|
||||
```
|
||||
|
||||
And not, not used this function in production.
|
||||
|
||||
|
||||
<BR>
|
||||
|
||||
## Info debug
|
||||
|
@ -119,4 +163,4 @@ def info_debug()
|
|||
return
|
||||
```
|
||||
|
||||
![image](uploads/9fee7144eaf111b32faeab5d7d6333f5/image.png)
|
||||
![image](uploads/9fee7144eaf111b32faeab5d7d6333f5/image.png)
|
||||
|
|
Loading…
Reference in New Issue