viz: Show type incompatibility errors
Solves https://github.com/veyron/release-issues/issues/1088
https://screenshot.googleplex.com/CDeqsRTYgs
We needed to show the error message.
I also make sure to treat undefined as '' in makeRPC so that we don't
learn it incorrectly.
Change-Id: I6521f06cec1d8d5e5439f9ba3dde064df88d7d29
diff --git a/src/components/browse/item-details/method-form/make-rpc.js b/src/components/browse/item-details/method-form/make-rpc.js
index 7a93500..5cdacbf 100644
--- a/src/components/browse/item-details/method-form/make-rpc.js
+++ b/src/components/browse/item-details/method-form/make-rpc.js
@@ -17,6 +17,8 @@
// Parse if possible. Otherwise, a string (or invalid JSON) will be used.
// Solves a problem where booleans did not seem to be parsed properly.
var args = data.args.map(function(arg) {
+ arg = arg || ''; // 'undefined' input should be treated as ''.
+
try {
return JSON.parse(arg);
} catch(e) {
diff --git a/src/components/browse/item-details/plugins/error.js b/src/components/browse/item-details/plugins/error.js
index 63f2f52..2706995 100644
--- a/src/components/browse/item-details/plugins/error.js
+++ b/src/components/browse/item-details/plugins/error.js
@@ -16,12 +16,18 @@
* Print the error with a dangerous-looking icon.
*/
function format(input) {
+ var error;
+ if (input.message) {
+ error = input.message;
+ } else {
+ error = input.toString();
+ }
return h('div', [
h('core-icon.error', {
attributes: {
'icon': 'error'
}
}),
- h('pre', JSON.stringify(input, null, 2))
+ h('pre', error)
]);
}