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

box API to return last error (code, message, type, errno, etc) #314

Closed
rtsisyk opened this issue May 26, 2014 · 0 comments
Closed

box API to return last error (code, message, type, errno, etc) #314

rtsisyk opened this issue May 26, 2014 · 0 comments
Assignees
Labels
feature A new functionality
Milestone

Comments

@rtsisyk
Copy link
Contributor

rtsisyk commented May 26, 2014

Implement two new calls:
box.error.last() - returns last error, if any, as a Lua table
box.error.clear() - clears the last error
And add an alias for box.error():
box.error.raise()

Example:

box.error.last()

---
- null
...
box.error({code = 123, reason = 'test'})

---
- error: test
...
box.error(box.error.ILLEGAL_PARAMS, "bla bla")

---
- error: Illegal parameters, bla bla
...
box.error.last()

---
- type: ClientError
  message: Illegal parameters, bla bla
  code: 1
...
box.error.clear()

---
...
box.error.last()

---
- null
...

Observe, that the returned lua table has three members:

  • type: C++ class type of the error
  • message: string message for the error
  • code: numeric code of the error, as passed to box.error(), usually one of the codes in box.error Lua table

Additionally, if the error is a system error (socket, file or memory related) a new member 'errno' contains C standard errno.

@rtsisyk rtsisyk added this to the 1.6.3 milestone May 26, 2014
@rtsisyk rtsisyk modified the milestones: 1.7, 1.6.3 Jul 15, 2014
@kostja kostja changed the title Return Tarantool error code on in pcall() Return last error without re-throw Apr 28, 2015
@kostja kostja changed the title Return last error without re-throw box API to return last error (code, message, type, errno, etc) Apr 28, 2015
@kostja kostja modified the milestones: 1.6.6, 1.7 Apr 28, 2015
@kostja kostja self-assigned this Apr 28, 2015
@kostja kostja added feature A new functionality and removed raw idea labels Apr 28, 2015
kostja added a commit that referenced this issue Apr 28, 2015
* implement two new calls:
  box.error.last() - returns last error, if any, as a Lua table
  box.error.clear() - clears the last error

* add an alias for box.error(), box.error.raise()
@kostja kostja closed this as completed Apr 28, 2015
pgulutzan added a commit to ocelot-inc/tarantool that referenced this issue May 4, 2015
llelik8 pushed a commit that referenced this issue Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality
Projects
None yet
Development

No branches or pull requests

2 participants