Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
744b5a6f
Commit
744b5a6f
authored
Apr 04, 2019
by
Piotr Gawron
Browse files
when plugin listener crash system notifies user and plugin about a problem
parent
90c77341
Pipeline
#9663
passed with stage
in 10 minutes and 42 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
744b5a6f
...
...
@@ -31,6 +31,8 @@ minerva (12.3.0~alpha.0) unstable; urgency=low
(#
591
)
*
Small
improvement
:
uploading
sbml
file
should
automatically
discover
a
file
type
(#
784
)
*
Small
improvement
:
when
plugin
listeners
crash
the
system
notifies
user
about
problem
with
a
plugin
(#
767
)
*
Bug
fix
:
progress
bar
of
gene
genome
mapping
upload
is
refreshing
properly
(#
728
)
*
Bug
fix
:
when
editing
project
Disease
and
Organism
could
not
be
removed
...
...
frontend-js/src/main/js/plugin/MinervaPluginProxy.js
View file @
744b5a6f
...
...
@@ -12,6 +12,8 @@ var Configuration = require('../Configuration');
var
Bounds
=
require
(
'
../map/canvas/Bounds
'
);
var
Point
=
require
(
'
../map/canvas/Point
'
);
var
GuiConnector
=
require
(
'
../GuiConnector
'
);
// noinspection JSUnusedLocalSymbols
var
logger
=
require
(
'
../logger
'
);
...
...
@@ -453,7 +455,7 @@ function createProjectMap(options) {
return
dbOverlay
.
searchByQuery
(
params
.
query
,
params
.
perfect
,
params
.
fitBounds
);
}
else
if
(
dbOverlay
instanceof
SearchDbOverlay
)
{
var
zoom
=
params
.
zoom
;
if
(
zoom
===
undefined
)
{
if
(
zoom
===
undefined
)
{
zoom
=
map
.
getSubmapById
(
params
.
modelId
).
getZoom
();
}
return
dbOverlay
.
searchByCoordinates
({
...
...
@@ -582,10 +584,26 @@ function createProjectMap(options) {
throw
new
Error
(
"
Invalid argument
"
);
}
var
wrapper
=
function
(
e
)
{
try
{
return
Promise
.
resolve
(
listenerWrapper
(
e
)).
catch
(
function
(
error
)
{
GuiConnector
.
warn
(
"
Plugin
"
+
options
.
plugin
.
getName
()
+
"
crashed
"
);
if
(
typeof
options
.
plugin
.
getLoadedPluginData
().
notifyError
===
"
function
"
)
{
options
.
plugin
.
getLoadedPluginData
().
notifyError
({
listener
:
param
,
data
:
e
,
error
:
error
});
}
});
}
catch
(
error
)
{
GuiConnector
.
warn
(
"
Plugin
"
+
options
.
plugin
.
getName
()
+
"
crashed
"
);
if
(
typeof
options
.
plugin
.
getLoadedPluginData
().
notifyError
===
"
function
"
)
{
options
.
plugin
.
getLoadedPluginData
().
notifyError
({
listener
:
param
,
data
:
e
,
error
:
error
});
}
}
};
for
(
var
i
=
0
;
i
<
objects
.
length
;
i
++
)
{
var
object
=
objects
[
i
];
object
.
addListener
(
listenerType
,
listenerW
rapper
);
listenersData
.
push
({
listener
:
param
.
callback
,
wrapper
:
listenerW
rapper
,
object
:
object
,
type
:
listenerType
});
object
.
addListener
(
listenerType
,
w
rapper
);
listenersData
.
push
({
listener
:
param
.
callback
,
wrapper
:
w
rapper
,
object
:
object
,
type
:
listenerType
});
}
},
/**
...
...
frontend-js/src/main/js/plugin/Plugin.js
View file @
744b5a6f
...
...
@@ -24,6 +24,7 @@ var pluginId = 0;
* @typedef {Object} UserPluginObject
* @property {function(Object):void} register
* @property {function():void} unregister
* @property {function(Object):void} [notifyError]
* @property {function():string} getName
* @property {function():string} getVersion
* @property {function():(number|string)|number|string} minWidth
...
...
frontend-js/src/test/js/plugin/Plugin-test.js
View file @
744b5a6f
...
...
@@ -5,6 +5,7 @@ require("../mocha-config");
// noinspection JSUnusedLocalSymbols
var
Promise
=
require
(
"
bluebird
"
);
var
Plugin
=
require
(
'
../../../main/js/plugin/Plugin
'
);
var
Point
=
require
(
'
../../../main/js/map/canvas/Point
'
);
var
ServerConnector
=
require
(
'
../ServerConnector-mock
'
);
var
logger
=
require
(
'
../logger
'
);
...
...
@@ -106,4 +107,14 @@ describe('Plugin', function () {
});
});
});
it
(
'
plugin listener crash
'
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
plugin
=
createPlugin
(
"
./testFiles/plugin/listener-crash.js
"
,
map
);
return
plugin
.
load
().
then
(
function
()
{
return
map
.
callListeners
(
"
onCenterChanged
"
,
new
Point
(
0
,
0
));
}).
then
(
function
()
{
assert
.
equal
(
1
,
logger
.
getWarnings
().
length
);
});
});
});
frontend-js/testFiles/apiCalls/plugins/POST_hash=a794c40b7ed8f56406f66f2913543915&isPublic=false&name=test%20plugin&url=.%2FtestFiles%2Fplugin%2Flistener-crash.js&version=0.0.1&token=MOCK_TOKEN_ID&
0 → 100644
View file @
744b5a6f
{
"hash": "d5d652ac0e0f6467d4cb6a742f99d3f7",
"name": "test plugin",
"urls": [
"./testFiles/plugin-invalid/invalid_register.js"
],
"version": "0.0.1"
}
\ No newline at end of file
frontend-js/testFiles/plugin/listener-crash.js
0 → 100644
View file @
744b5a6f
minervaDefine
(
function
()
{
return
{
register
:
function
(
minervaObject
)
{
var
options
=
{
object
:
"
map
"
,
type
:
"
onCenterChanged
"
,
callback
:
function
()
{
throw
new
Error
(
"
Let's crash
"
);
}
};
minervaObject
.
project
.
map
.
addListener
(
options
);
},
unregister
:
function
()
{
console
.
log
(
"
unregistering test plugin
"
);
},
getName
:
function
()
{
return
"
test plugin
"
;
},
getVersion
:
function
()
{
return
"
0.0.1
"
;
}
};
});
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment