good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
0d6479e1
Commit
0d6479e1
authored
Nov 7, 2014
by
Marek Kotewicz
Browse files
Options
Downloads
Patches
Plain Diff
proper error handling proposal
parent
b0e11826
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
httprpc.js
+3
-2
3 additions, 2 deletions
httprpc.js
main.js
+15
-11
15 additions, 11 deletions
main.js
with
18 additions
and
13 deletions
httprpc.js
+
3
−
2
View file @
0d6479e1
...
@@ -40,7 +40,8 @@
...
@@ -40,7 +40,8 @@
return
{
return
{
_id
:
object
.
id
,
_id
:
object
.
id
,
data
:
object
.
result
data
:
object
.
result
,
error
:
object
.
error
};
};
};
};
...
@@ -70,7 +71,7 @@
...
@@ -70,7 +71,7 @@
var
self
=
this
;
var
self
=
this
;
this
.
sendRequest
(
payload
,
function
(
request
)
{
this
.
sendRequest
(
payload
,
function
(
request
)
{
var
parsed
=
JSON
.
parse
(
request
.
responseText
);
var
parsed
=
JSON
.
parse
(
request
.
responseText
);
if
(
parsed
.
result
instanceof
Array
?
parsed
.
result
.
length
===
0
:
!
parsed
.
result
)
{
if
(
parsed
.
error
||
(
parsed
.
result
instanceof
Array
?
parsed
.
result
.
length
===
0
:
!
parsed
.
result
)
)
{
return
;
return
;
}
}
self
.
handlers
.
forEach
(
function
(
handler
)
{
self
.
handlers
.
forEach
(
function
(
handler
)
{
...
...
This diff is collapsed.
Click to expand it.
main.js
+
15
−
11
View file @
0d6479e1
...
@@ -153,12 +153,12 @@
...
@@ -153,12 +153,12 @@
return
{
call
:
call
,
args
:
args
};
return
{
call
:
call
,
args
:
args
};
}).
then
(
function
(
request
)
{
}).
then
(
function
(
request
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
web3
.
provider
.
send
(
request
,
function
(
result
)
{
web3
.
provider
.
send
(
request
,
function
(
err
,
result
)
{
if
(
result
||
typeof
result
===
"
boolean
"
)
{
if
(
!
err
)
{
resolve
(
result
);
resolve
(
result
);
return
;
return
;
}
}
reject
(
result
);
reject
(
err
);
});
});
});
});
}).
catch
(
function
(
err
)
{
}).
catch
(
function
(
err
)
{
...
@@ -173,8 +173,12 @@
...
@@ -173,8 +173,12 @@
var
proto
=
{};
var
proto
=
{};
proto
.
get
=
function
()
{
proto
.
get
=
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
web3
.
provider
.
send
({
call
:
property
.
getter
},
function
(
result
)
{
web3
.
provider
.
send
({
call
:
property
.
getter
},
function
(
err
,
result
)
{
if
(
!
err
)
{
resolve
(
result
);
resolve
(
result
);
return
}
reject
(
err
);
});
});
});
});
};
};
...
@@ -182,12 +186,12 @@
...
@@ -182,12 +186,12 @@
proto
.
set
=
function
(
val
)
{
proto
.
set
=
function
(
val
)
{
return
flattenPromise
([
val
]).
then
(
function
(
args
)
{
return
flattenPromise
([
val
]).
then
(
function
(
args
)
{
return
new
Promise
(
function
(
resolve
)
{
return
new
Promise
(
function
(
resolve
)
{
web3
.
provider
.
send
({
call
:
property
.
setter
,
args
:
args
},
function
(
result
)
{
web3
.
provider
.
send
({
call
:
property
.
setter
,
args
:
args
},
function
(
err
,
result
)
{
if
(
result
)
{
if
(
!
err
)
{
resolve
(
result
);
resolve
(
result
);
}
else
{
return
reject
(
result
);
}
}
reject
(
err
);
});
});
});
});
}).
catch
(
function
(
err
)
{
}).
catch
(
function
(
err
)
{
...
@@ -438,7 +442,7 @@
...
@@ -438,7 +442,7 @@
if
(
data
.
_id
)
{
if
(
data
.
_id
)
{
var
cb
=
web3
.
_callbacks
[
data
.
_id
];
var
cb
=
web3
.
_callbacks
[
data
.
_id
];
if
(
cb
)
{
if
(
cb
)
{
cb
.
call
(
this
,
data
.
data
)
cb
.
call
(
this
,
data
.
error
,
data
.
data
)
delete
web3
.
_callbacks
[
data
.
_id
];
delete
web3
.
_callbacks
[
data
.
_id
];
}
}
}
}
...
...
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