Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
d0422855
Commit
d0422855
authored
Jun 25, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ScopeError
This will simplify error catching.
parent
cabb9e43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
renderjs.js
renderjs.js
+18
-2
test/renderjs_test.js
test/renderjs_test.js
+2
-2
No files found.
renderjs.js
View file @
d0422855
...
...
@@ -10,6 +10,19 @@
Event
,
URL
)
{
"
use strict
"
;
/////////////////////////////////////////////////////////////////
// Error
/////////////////////////////////////////////////////////////////
function
ScopeError
(
message
)
{
this
.
name
=
"
scopeerror
"
;
if
((
message
!==
undefined
)
&&
(
typeof
message
!==
"
string
"
))
{
throw
new
TypeError
(
'
You must pass a string.
'
);
}
this
.
message
=
message
||
"
Scope Error
"
;
}
ScopeError
.
prototype
=
new
Error
();
ScopeError
.
prototype
.
constructor
=
ScopeError
;
function
ensurePushableQueue
(
callback
,
argument_list
,
context
)
{
var
result
;
try
{
...
...
@@ -1130,13 +1143,15 @@
.
declareMethod
(
'
getDeclaredGadget
'
,
function
getDeclaredGadget
(
gadget_scope
)
{
if
(
!
this
.
__sub_gadget_dict
.
hasOwnProperty
(
gadget_scope
))
{
throw
new
Error
(
"
Gadget scope '
"
+
gadget_scope
+
"
' is not known.
"
);
throw
new
ScopeError
(
"
Gadget scope '
"
+
gadget_scope
+
"
' is not known.
"
);
}
return
this
.
__sub_gadget_dict
[
gadget_scope
];
})
.
declareMethod
(
'
dropGadget
'
,
function
dropGadget
(
gadget_scope
)
{
if
(
!
this
.
__sub_gadget_dict
.
hasOwnProperty
(
gadget_scope
))
{
throw
new
Error
(
"
Gadget scope '
"
+
gadget_scope
+
"
' is not known.
"
);
throw
new
ScopeError
(
"
Gadget scope '
"
+
gadget_scope
+
"
' is not known.
"
);
}
// http://perfectionkills.com/understanding-delete/
delete
this
.
__sub_gadget_dict
[
gadget_scope
];
...
...
@@ -1453,6 +1468,7 @@
// global
/////////////////////////////////////////////////////////////////
renderJS
.
Mutex
=
Mutex
;
renderJS
.
ScopeError
=
ScopeError
;
window
.
rJS
=
window
.
renderJS
=
renderJS
;
window
.
__RenderJSGadget
=
RenderJSGadget
;
window
.
__RenderJSEmbeddedGadget
=
RenderJSEmbeddedGadget
;
...
...
test/renderjs_test.js
View file @
d0422855
...
...
@@ -5777,7 +5777,7 @@
ok
(
false
,
"
getDeclaredGadget should fail
"
);
})
.
fail
(
function
(
e
)
{
ok
(
e
instanceof
Error
);
ok
(
e
instanceof
rJS
.
Scope
Error
);
equal
(
e
.
message
,
"
Gadget scope 'foo' is not known.
"
);
})
.
always
(
function
()
{
...
...
@@ -5820,7 +5820,7 @@
ok
(
false
,
"
dropGadget should fail
"
);
})
.
fail
(
function
(
e
)
{
ok
(
e
instanceof
Error
);
ok
(
e
instanceof
rJS
.
Scope
Error
);
equal
(
e
.
message
,
"
Gadget scope 'foo' is not known.
"
);
})
.
always
(
function
()
{
...
...
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