Skip to content

Commit 6703b04

Browse files
committed
Elaborate on documentation for exceptions
1 parent f3b0d90 commit 6703b04

2 files changed

Lines changed: 41 additions & 4 deletions

File tree

rivescript/exceptions.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ def __init__(self, error_message=None):
4444
class NoMatchError(RiveScriptError):
4545
"""No reply could be matched.
4646
47+
This means that no trigger was a match for the user's message. To avoid
48+
this error, add a trigger that only consists of a wildcard::
49+
50+
+ *
51+
- I do not know how to reply to that.
52+
53+
The lone-wildcard trigger acts as a catch-all fallback trigger and will
54+
ensure that every message the user could send will match at least one
55+
trigger.
56+
4757
The text version is ``[ERR: No reply matched]``
4858
"""
4959
def __init__(self):
@@ -53,14 +63,25 @@ def __init__(self):
5363
class NoReplyError(RiveScriptError):
5464
"""No reply could be found.
5565
66+
This means that the user's message matched a trigger, but the trigger
67+
didn't yield any response for the user. For example, if a trigger was
68+
followed only by ``*Conditions`` and none of them were true and there were
69+
no normal replies to fall back on, this error can come up.
70+
71+
To avoid this error, always make sure you have at least one ``-Reply``
72+
for every trigger.
73+
5674
The text version is ``[ERR: No reply found]``.
5775
"""
5876
def __init__(self):
5977
super(NoReplyError, self).__init__(RS_ERR_REPLY)
6078

6179

6280
class ObjectError(RiveScriptError):
63-
"""An error occurred when executing a Python object.
81+
"""An error occurred when executing a Python object macro.
82+
83+
This will usually be some kind of run-time error, like a
84+
``ZeroDivisionError`` or ``IndexError`` for example.
6485
6586
The text version is ``[ERR: Error when executing Python object]``
6687
"""
@@ -71,6 +92,23 @@ def __init__(self, error_message=RS_ERR_OBJECT):
7192
class DeepRecursionError(RiveScriptError):
7293
"""A deep recursion condition was detected and a reply can't be given.
7394
95+
This error can occur when you have triggers that redirect to each other
96+
in a circle, for example::
97+
98+
+ one
99+
@ two
100+
101+
+ two
102+
@ one
103+
104+
By default, RiveScript will only recursively look for a trigger up to
105+
50 levels deep before giving up. This should be a large enough window for
106+
most use cases, but if you need to increase this limit you can do so by
107+
setting a higher value for the ``depth`` parameter to the constructor or
108+
changing it in your RiveScript source code, for example::
109+
110+
! global depth = 75
111+
74112
The text version is ``[ERR: Deep recursion detected]``
75113
"""
76114
def __init__(self):

rivescript/python.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ def __init__(self):
6060
def load(self, name, code):
6161
"""Prepare a Python code object given by the RiveScript interpreter.
6262
63-
Args:
64-
name (str): The name of the Python object macro.
65-
code ([]str): The Python source code for the object macro.
63+
:param str name: The name of the Python object macro.
64+
:param []str code: The Python source code for the object macro.
6665
"""
6766
# We need to make a dynamic Python method.
6867
source = "def RSOBJ(rs, args):\n"

0 commit comments

Comments
 (0)