Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
6cb39dd3
Commit
6cb39dd3
authored
Jan 09, 2017
by
Péter Szilágyi
Committed by
GitHub
Jan 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3529 from fjl/console-error-fix
console: fix error message in faux JSON-RPC responses
parents
88cc1ca5
9bab0b8a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
12 deletions
+5
-12
bridge.go
console/bridge.go
+5
-12
No files found.
console/bridge.go
View file @
6cb39dd3
...
...
@@ -270,18 +270,15 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) {
}
else
{
resultVal
,
err
:=
JSON
.
Call
(
"parse"
,
string
(
result
))
if
err
!=
nil
{
resp
=
newErrorResponse
(
call
,
-
32603
,
err
.
Error
(),
&
req
.
Id
)
.
Object
(
)
setError
(
resp
,
-
32603
,
err
.
Error
()
)
}
else
{
resp
.
Set
(
"result"
,
resultVal
)
}
}
case
rpc
.
Error
:
resp
.
Set
(
"error"
,
map
[
string
]
interface
{}{
"code"
:
err
.
ErrorCode
(),
"message"
:
err
.
Error
(),
})
setError
(
resp
,
err
.
ErrorCode
(),
err
.
Error
())
default
:
resp
=
newErrorResponse
(
call
,
-
32603
,
err
.
Error
(),
&
req
.
Id
)
.
Object
(
)
setError
(
resp
,
-
32603
,
err
.
Error
()
)
}
resps
.
Call
(
"push"
,
resp
)
}
...
...
@@ -300,12 +297,8 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) {
return
response
}
func
newErrorResponse
(
call
otto
.
FunctionCall
,
code
int
,
msg
string
,
id
interface
{})
otto
.
Value
{
// Bundle the error into a JSON RPC call response
m
:=
map
[
string
]
interface
{}{
"version"
:
"2.0"
,
"id"
:
id
,
"error"
:
map
[
string
]
interface
{}{
"code"
:
code
,
msg
:
msg
}}
res
,
_
:=
json
.
Marshal
(
m
)
val
,
_
:=
call
.
Otto
.
Run
(
"("
+
string
(
res
)
+
")"
)
return
val
func
setError
(
resp
*
otto
.
Object
,
code
int
,
msg
string
)
{
resp
.
Set
(
"error"
,
map
[
string
]
interface
{}{
"code"
:
code
,
"message"
:
msg
})
}
// throwJSException panics on an otto.Value. The Otto VM will recover from the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment