1313
1414``` lua
1515self .client .request (' workspace/executeCommand' , cmd_info , function (err , res )
16- if err then
17- log .error (command .. ' failed! arguments: ' , arguments , ' error: ' , err )
18- else
19- log .debug (command .. ' success! response: ' , res )
20- end
16+ if err then
17+ log .error (command .. ' failed! arguments: ' , arguments , ' error: ' , err )
18+ else
19+ log .debug (command .. ' success! response: ' , res )
20+ end
2121end , buffer )
2222```
2323
@@ -33,14 +33,14 @@ Assume following is the asynchronous API
3333
3434``` lua
3535local function lsp_request (callback )
36- local timer = vim .loop .new_timer ()
36+ local timer = vim .loop .new_timer ()
3737
38- assert (timer )
38+ assert (timer )
3939
40- timer :start (2000 , 0 , function ()
41- -- First parameter is the error
42- callback (' something went wrong' , nil )
43- end )
40+ timer :start (2000 , 0 , function ()
41+ -- First parameter is the error
42+ callback (' something went wrong' , nil )
43+ end )
4444end
4545```
4646
@@ -52,7 +52,7 @@ This is how you can call this asynchronous API without a callback
5252local M = require (' sync' )
5353
5454M .sync (function ()
55- local response = M .wait_handle_error (M .wrap (lsp_request )())
55+ local response = M .wait_handle_error (M .wrap (lsp_request )())
5656end ).run ()
5757```
5858
@@ -62,9 +62,9 @@ Result:
6262Error executing luv callback:
6363test6.lua:43: unhandled error test6.lua:105: something went wrong
6464stack traceback:
65- [C]: in function 'error'
66- test6.lua:43: in function 'callback'
67- test6.lua:130: in function <test6.lua:129>
65+ [C]: in function 'error'
66+ test6.lua:43: in function 'callback'
67+ test6.lua:130: in function <test6.lua:129>
6868```
6969
7070### When error handler is defined
@@ -73,12 +73,12 @@ stack traceback:
7373local M = require (' sync' )
7474
7575local main = M .sync (function ()
76- local response = M .wait_handle_error (M .wrap (lsp_request )())
76+ local response = M .wait_handle_error (M .wrap (lsp_request )())
7777end )
78- .catch (function (err )
79- print (' error occurred ' , err )
80- end )
81- .run ()
78+ .catch (function (err )
79+ print (' error occurred ' , err )
80+ end )
81+ .run ()
8282```
8383
8484Result:
@@ -93,16 +93,16 @@ error occured test6.lua:105: something went wrong
9393local M = require (' sync' )
9494
9595local nested = M .sync (function ()
96- local response = M .wait_handle_error (M .wrap (lsp_request )())
96+ local response = M .wait_handle_error (M .wrap (lsp_request )())
9797end )
9898
9999M .sync (function ()
100- M .wait_handle_error (nested .run )
100+ M .wait_handle_error (nested .run )
101101end )
102- .catch (function (err )
103- print (' parent error handler ' .. err )
104- end )
105- .run ()
102+ .catch (function (err )
103+ print (' parent error handler ' .. err )
104+ end )
105+ .run ()
106106```
107107
108108Result:
0 commit comments