Skip to content
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

Merged
merged 1 commit into from
Aug 28, 2023
Merged

Update docs for errors #3618

merged 1 commit into from
Aug 28, 2023

Conversation

andreyaksenov
Copy link
Contributor

@andreyaksenov andreyaksenov commented Aug 15, 2023

Updated docs for the box.error module and some related topics:

The error_marshaling_enabled option was removed in 2.10:

The updated docs use testable code snippets from the code_snippets folder. The referenced code snippets is included to help pages using special -- snippet_start and -- snippet_end comments.

@andreyaksenov andreyaksenov force-pushed the box-error branch 8 times, most recently from 7d30d2d to 14a8f8c Compare August 16, 2023 10:52
@andreyaksenov andreyaksenov linked an issue Aug 16, 2023 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the box-error branch 4 times, most recently from 161c7d1 to ea46cac Compare August 17, 2023 09:35
@andreyaksenov andreyaksenov linked an issue Aug 17, 2023 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the box-error branch 5 times, most recently from eb5510d to d9a96eb Compare August 17, 2023 12:58
@andreyaksenov andreyaksenov linked an issue Aug 17, 2023 that may be closed by this pull request
8 tasks
@andreyaksenov andreyaksenov force-pushed the box-error branch 10 times, most recently from 7f88e88 to 7077e2f Compare August 21, 2023 07:33
@andreyaksenov andreyaksenov linked an issue Aug 21, 2023 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the box-error branch 18 times, most recently from 98ae6c8 to a330081 Compare August 23, 2023 08:29
Copy link
Contributor

@sergepetrenko sergepetrenko left a 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.

doc/reference/reference_lua/errcodes.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@p7nov p7nov left a 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.

Copy link
Contributor

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'
...

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* :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``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``ClientError`` or ``OurOfMemory``.
``ClientError`` or ``OutOfMemory``.

box.error(type, reason[, ...])
******************************

This example shows how to raise an error with the specified type and reason:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

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:"

Copy link
Contributor Author

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.

@andreyaksenov andreyaksenov merged commit b714c12 into latest Aug 28, 2023
1 check passed
@andreyaksenov andreyaksenov deleted the box-error branch August 28, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants