aboutsummaryrefslogtreecommitdiffstats
path: root/jsre
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-04-02 07:53:33 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-04-02 07:53:33 +0800
commitbb3ae3026edec431c59299271f1af682e8dbb938 (patch)
treea0f7742d0ce31e5607d471a2d796b24dd993e0ca /jsre
parentb8124ec79182dbf90b28c8527f2440cea6473f1b (diff)
downloadgo-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.tar
go-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.tar.gz
go-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.tar.bz2
go-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.tar.lz
go-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.tar.xz
go-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.tar.zst
go-tangerine-bb3ae3026edec431c59299271f1af682e8dbb938.zip
print nonenumerable properties of object in geth console
Diffstat (limited to 'jsre')
-rw-r--r--jsre/pp_js.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/jsre/pp_js.go b/jsre/pp_js.go
index 3352f23ce..78509fc0b 100644
--- a/jsre/pp_js.go
+++ b/jsre/pp_js.go
@@ -23,18 +23,26 @@ function pp(object, indent) {
}
}
str += " ]";
+ } else if (object instanceof Error) {
+ str += "\033[31m" + "Error";
} else if(typeof(object) === "object") {
str += "{\n";
- indent += " ";
- var last = Object.keys(object).pop()
- for(var k in object) {
- str += indent + k + ": " + pp(object[k], indent);
+ indent += " ";
+ var last = Object.getOwnPropertyNames(object).pop()
+ Object.getOwnPropertyNames(object).forEach(function (k) {
+ str += indent + k + ": ";
+ try {
+ str += pp(object[k], indent);
+ } catch (e) {
+ str += pp(e, indent);
+ }
if(k !== last) {
str += ",";
}
- str += "\n";
- }
+
+ str += "\n";
+ });
str += indent.substr(2, indent.length) + "}";
} else if(typeof(object) === "string") {
str += "\033[32m'" + object + "'";
@@ -43,7 +51,7 @@ function pp(object, indent) {
} else if(typeof(object) === "number") {
str += "\033[31m" + object;
} else if(typeof(object) === "function") {
- str += "\033[35m[Function]";
+ str += "\033[35m[Function]";
} else {
str += object;
}