Skip to content

Commit 93ba1b2

Browse files
authored
Add name parameter and box.error.is function description to box.error. (#5112)
* Add description of the ``name`` parameter Since 3.1.0 there has been the ``name`` parameter,which returns the name of the error used at creation. * Add description of box.error.is function Function allows check whether the argument is an error. Added as a new page Fixes #4236, #4150
1 parent a99dacd commit 93ba1b2

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

doc/reference/reference_lua/box_error.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ Below is a list of ``box.error`` functions and related objects.
275275

276276
* - :doc:`./box_error/set`
277277
- Set the specified error as the last system error explicitly
278+
279+
* - :doc:`./box_error/is`
280+
- Verify whether the specified argument is an error cdata object
278281

279282
* - :doc:`./box_error/error_object`
280283
- An object that defines an error
@@ -288,4 +291,5 @@ Below is a list of ``box.error`` functions and related objects.
288291
box_error/clear
289292
box_error/new
290293
box_error/set
294+
box_error/is
291295
box_error/error_object

doc/reference/reference_lua/box_error/error_object.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,13 @@ error_object
189189

190190
For the ``box.error.READONLY`` error, returns the current election term (see :ref:`box.info.election.term <box_info_election>`).
191191
This attribute may present if the :ref:`error reason <box_error-reason>` is ``election`` or ``synchro``.
192+
193+
.. _box_error-name:
194+
195+
.. data:: name
196+
197+
**Since:** :doc:`3.1.0 </release/3.1.0>`
198+
199+
Returns the name of the error.
200+
201+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.. _box_error-is:
2+
3+
===============================================================================
4+
box.error.is()
5+
===============================================================================
6+
7+
.. function:: box.error.is(object)
8+
9+
**Since:** :doc:`3.2.0 </release/3.2.0>`
10+
11+
The ``box.error.is`` function allows verify whether the specified argument is an error cdata object.
12+
13+
:param object object: the object to be verified.
14+
15+
**Return type:**
16+
boolean
17+
18+
**Example**
19+
20+
.. code-block:: lua
21+
22+
tarantool> box.error.is(box.error.new(box.error.UNKNOWN))
23+
---
24+
- true
25+
...
26+
tarantool> box.error.is('foo')
27+
---
28+
- false
29+
...

0 commit comments

Comments
 (0)