Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
0c50bf69
Commit
0c50bf69
authored
10 years ago
by
Roman Tsisyk
Browse files
Options
Downloads
Patches
Plain Diff
Support for multireturn in wrapped pcall()
parent
d7661256
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lua/init.lua
+7
-4
7 additions, 4 deletions
src/lua/init.lua
test/app/pcall.result
+2
-0
2 additions, 0 deletions
test/app/pcall.result
test/app/pcall.test.lua
+3
-0
3 additions, 0 deletions
test/app/pcall.test.lua
with
12 additions
and
4 deletions
src/lua/init.lua
+
7
−
4
View file @
0c50bf69
...
...
@@ -9,10 +9,13 @@ tarantool_error_message(void);
]]
local
pcall_lua
=
pcall
pcall
=
function
(
fun
,
...
)
local
status
,
msg
=
pcall_lua
(
fun
,
...
)
if
status
==
false
and
msg
==
'C++ exception'
then
local
function
pcall_wrap
(
status
,
...
)
if
status
==
false
and
...
==
'C++ exception'
then
return
false
,
ffi
.
string
(
ffi
.
C
.
tarantool_error_message
())
end
return
status
,
msg
return
status
,
...
end
pcall
=
function
(
fun
,
...
)
return
pcall_wrap
(
pcall_lua
(
fun
,
...
))
end
This diff is collapsed.
Click to expand it.
test/app/pcall.result
+
2
−
0
View file @
0c50bf69
...
...
@@ -5,3 +5,5 @@
pcall inside xpcall: true pcall is ok
pcall with Lua error(): false some message
pcall with box.raise(): false some message
pcall with no return: 1
pcall with multireturn: true 1 2 3
This diff is collapsed.
Click to expand it.
test/app/pcall.test.lua
+
3
−
0
View file @
0c50bf69
...
...
@@ -28,3 +28,6 @@ local status, msg = pcall(function()
box
.
raise
(
box
.
error
.
ER_ILLEGAL_PARAMS
,
'some message'
)
end
)
print
(
'pcall with box.raise():'
,
status
,
msg
)
print
(
'pcall with no return:'
,
select
(
'#'
,
pcall
(
function
()
end
)))
print
(
'pcall with multireturn:'
,
pcall
(
function
()
return
1
,
2
,
3
end
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment