-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update docs for errors #3618
Update docs for errors #3618
Conversation
7d30d2d
to
14a8f8c
Compare
161c7d1
to
ea46cac
Compare
eb5510d
to
d9a96eb
Compare
7f88e88
to
7077e2f
Compare
98ae6c8
to
a330081
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
Just one comment from me.
a330081
to
f07ed6d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
Some comments from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snippet works as a whole, but when I run only box.error(custom_error
, I get box.error(): bad arguments
for some reason:
tarantool> local custom_error = box.error.new({ code = 500,
reason = 'Internal server error' })
box.error(custom_error)
---
- error: Internal server error
...
tarantool> box.error(custom_error)
---
- error: 'box.error(): bad arguments'
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this issue is related to a variable visibility scope - local variables are not available in the next console console operation. If you declare custom_error
without the local
modifier, all should work fine.
|
||
The following ``box.error()`` overloads are available for raising a custom error: | ||
|
||
* :ref:`box.error({ reason = string[, code = number, type = string] }) <box_error-error-table>` accepts a Lua table that enables you to specify the error reason, code, and type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* :ref:`box.error({ reason = string[, code = number, type = string] }) <box_error-error-table>` accepts a Lua table that enables you to specify the error reason, code, and type. | |
* :ref:`box.error({ reason = string[, code = number, type = string] }) <box_error-error-table>` accepts a Lua table containing the error reason, code, and type. |
"table enables you to specify" sounds wordy and vague.
|
||
When a custom type is specified, it is returned in the :ref:`error_object.type <box_error-type>` attribute. | ||
When it is not specified, ``error_object.type`` returns one of the built-in errors, such as | ||
``ClientError`` or ``OurOfMemory``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``ClientError`` or ``OurOfMemory``. | |
``ClientError`` or ``OutOfMemory``. |
box.error(type, reason[, ...]) | ||
****************************** | ||
|
||
This example shows how to raise an error with the specified type and reason: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example shows how to raise an error with the specified type and reason: | |
This example shows how to raise an error with the type and reason specified | |
in the ``box.error()`` arguments: |
To highlight the difference with error parameters in a table.
- box.error.WAL_IO | ||
- Failed to write to disk. May mean: failed to record a change in the write-ahead log. | ||
|
||
* - ER_READONLY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a link to descriptions of specific parameters in error_object reference?
|
||
.. function:: box.error.new({ reason = string[, code = number, type = string] }) | ||
|
||
Create the error defined by the specified parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create the error defined by the specified parameters. | |
Create an error object with the specified parameters. |
To avoid unnecessary passive voice.
Also, the point that this method does not raise the error looks useful to me here.
|
||
**Since:** :doc:`2.10.0 </release/2.10.0>` | ||
|
||
Returns the :ref:`box.info.ro_reason <box_introspection-box_info>` value at the moment of throwing the ``box.error.READONLY`` error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a unified note or intro phrase for all parameters that apply only to readonly error?
"Only for box.error.READONLY:"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following intro already used for such parameters: For the ``box.error.READONLY`` error,
. Here I use a slightly different description because this is the 'base' property for a read-only error and box.error.READONLY
already mentioned in the description.
f07ed6d
to
26a164f
Compare
Updated docs for the
box.error
module and some related topics:Submodule box.error
topic now has the overview on how to use the API: https://docs.d.tarantool.io/en/doc/box-error/reference/reference_lua/box_error/error_object
description now contains attributes related to replication errors (for example,error_object.reason
and related attributes): https://docs.d.tarantool.io/en/doc/box-error/reference/reference_lua/box_error/error_object/Database error codes
topic: https://docs.d.tarantool.io/en/doc/box-error/reference/reference_lua/errcodes/The
error_marshaling_enabled
option was removed in 2.10: