aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-19 16:33:29 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-19 16:33:29 +0100
commit2cd4a85ed4c57a705e3aeb88052be616e0461187 (patch)
tree7adf45ccda4eace9d350cb593ae19cd1151d300e
parent50090b5fb44f9d3986064dfe9b6190b66cbe49bf (diff)
downloadwallet-core-2cd4a85ed4c57a705e3aeb88052be616e0461187.tar.xz
better error reporting
-rw-r--r--src/logging.ts30
-rw-r--r--src/module-trampoline.js73
-rw-r--r--src/pages/confirm-contract.html2
-rw-r--r--src/pages/confirm-create-reserve.html2
-rw-r--r--src/pages/confirm-create-reserve.tsx24
-rw-r--r--src/pages/logs.html2
-rw-r--r--src/pages/logs.tsx1
-rw-r--r--src/pages/tree.html2
-rw-r--r--src/popup/popup.html2
-rw-r--r--src/wxBackend.ts2
-rw-r--r--tsconfig.json9
11 files changed, 54 insertions, 95 deletions
diff --git a/src/logging.ts b/src/logging.ts
index ff0987396..788a7df55 100644
--- a/src/logging.ts
+++ b/src/logging.ts
@@ -42,7 +42,7 @@ function makeDebug() {
export async function log(msg: string, level: Level = "info"): Promise<void> {
let ci = getCallInfo(2);
- return record(level, msg, ci.file, ci.line, ci.column);
+ return record(level, msg, undefined, ci.file, ci.line, ci.column);
}
function getCallInfo(level: number) {
@@ -113,9 +113,10 @@ export interface LogEntry {
timestamp: number;
level: string;
msg: string;
- source: string|undefined;
- col: number|undefined;
- line: number|undefined;
+ detail?: string;
+ source?: string;
+ col?: number;
+ line?: number;
id?: number;
}
@@ -133,7 +134,25 @@ export async function getLogs(): Promise<LogEntry[]> {
*/
let barrier: any;
-export async function record(level: Level, msg: string, source?: string, line?: number, col?: number): Promise<void> {
+export async function recordException(msg: string, e: any): Promise<void> {
+ let stack: string|undefined;
+ let frame: Frame|undefined;
+ try {
+ stack = e.stack;
+ if (stack) {
+ let lines = stack.split("\n");
+ frame = parseStackLine(lines[1]);
+ }
+ } catch (e) {
+ // ignore
+ }
+ if (!frame) {
+ frame = unknownFrame;
+ }
+ return record("error", e.toString(), stack, frame.file, frame.line, frame.column);
+}
+
+export async function record(level: Level, msg: string, detail?: string, source?: string, line?: number, col?: number): Promise<void> {
if (typeof indexedDB === "undefined") {
return;
}
@@ -166,6 +185,7 @@ export async function record(level: Level, msg: string, source?: string, line?:
source,
line,
col,
+ detail,
};
await new QueryRoot(db).put(logsStore, entry);
} finally {
diff --git a/src/module-trampoline.js b/src/module-trampoline.js
deleted file mode 100644
index 20ed91638..000000000
--- a/src/module-trampoline.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- This file is part of TALER
- (C) 2016 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-
-
-/**
- * Boilerplate to initialize the module system and call main()
- *
- * @author Florian Dold
- */
-
-"use strict";
-
-if (typeof System === "undefined") {
- throw Error("system loader not present (must be included before the" +
- " trampoline");
-}
-
-System.config({
- defaultJSExtensions: true,
- map: {
- src: "/src/",
- },
-});
-
-let me = window.location.protocol
- + "//" + window.location.host
- + window.location.pathname.replace(/[.]html$/, ".js");
-
-let domLoaded = false;
-
-document.addEventListener("DOMContentLoaded", function(event) {
- domLoaded = true;
-});
-
-function execMain(m) {
- if (m.main) {
- console.log("executing module main");
- let res = m.main();
- } else {
- console.warn("module does not export a main() function");
- }
-}
-
-console.log("loading", me);
-
-System.import(me)
- .then((m) => {
- console.log("module imported", me);
- if (domLoaded) {
- execMain(m);
- return;
- }
- document.addEventListener("DOMContentLoaded", function(event) {
- execMain(m);
- });
- })
- .catch((e) => {
- console.log("trampoline failed");
- console.error(e.stack);
- });
diff --git a/src/pages/confirm-contract.html b/src/pages/confirm-contract.html
index 54a4d618d..261609d1c 100644
--- a/src/pages/confirm-contract.html
+++ b/src/pages/confirm-contract.html
@@ -16,7 +16,7 @@
<!-- <script src="/src/vendor/jed.js"></script> -->
<script src="/src/i18n.js"></script>
<script src="/src/i18n/strings.js"></script>
- <script src="/src/module-trampoline.js"></script>
+ <script src="/src/moduleTrampoline.js"></script>
<style>
button.accept {
diff --git a/src/pages/confirm-create-reserve.html b/src/pages/confirm-create-reserve.html
index c67c7e960..b679de9c9 100644
--- a/src/pages/confirm-create-reserve.html
+++ b/src/pages/confirm-create-reserve.html
@@ -17,7 +17,7 @@
<!-- module loading -->
<script src="/src/vendor/system-csp-production.src.js"></script>
- <script src="/src/module-trampoline.js"></script>
+ <script src="/src/moduleTrampoline.js"></script>
<style>
diff --git a/src/pages/confirm-create-reserve.tsx b/src/pages/confirm-create-reserve.tsx
index 963bd0697..81a90650c 100644
--- a/src/pages/confirm-create-reserve.tsx
+++ b/src/pages/confirm-create-reserve.tsx
@@ -374,14 +374,24 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {
}
export async function main() {
- const url = URI(document.location.href);
- const query: any = URI.parseQuery(url.query());
- const amount = AmountJson.checked(JSON.parse(query.amount));
- const callback_url = query.callback_url;
- const bank_url = query.bank_url;
- const wt_types = JSON.parse(query.wt_types);
-
try {
+ const url = URI(document.location.href);
+ const query: any = URI.parseQuery(url.query());
+ let amount;
+ try {
+ amount = AmountJson.checked(JSON.parse(query.amount));
+ } catch (e) {
+ throw Error(`Can't parse amount: ${e.message}`);
+ }
+ const callback_url = query.callback_url;
+ const bank_url = query.bank_url;
+ let wt_types;
+ try {
+ wt_types = JSON.parse(query.wt_types);
+ } catch (e) {
+ throw Error(`Can't parse wire_types: ${e.message}`);
+ }
+
const suggestedExchangeUrl = await getSuggestedExchange(amount.currency);
let args = {
wt_types,
diff --git a/src/pages/logs.html b/src/pages/logs.html
index 8d35bcbd7..9178298f8 100644
--- a/src/pages/logs.html
+++ b/src/pages/logs.html
@@ -19,7 +19,7 @@
<script src="/src/i18n/strings.js"></script>
<script src="/src/vendor/system-csp-production.src.js"></script>
- <script src="/src/module-trampoline.js"></script>
+ <script src="/src/moduleTrampoline.js"></script>
<style>
.tree-item {
diff --git a/src/pages/logs.tsx b/src/pages/logs.tsx
index 126659fe7..15bb3d270 100644
--- a/src/pages/logs.tsx
+++ b/src/pages/logs.tsx
@@ -38,6 +38,7 @@ class LogView extends React.Component<LogViewProps, void> {
<li>file: {e.source || "(unknown)"}</li>
<li>line: {e.line || "(unknown)"}</li>
<li>col: {e.col || "(unknown)"}</li>
+ {(e.detail ? <li> detail: <pre>{e.detail}</pre></li> : [])}
</ul>
</div>
);
diff --git a/src/pages/tree.html b/src/pages/tree.html
index 306044159..4be7a5cdc 100644
--- a/src/pages/tree.html
+++ b/src/pages/tree.html
@@ -19,7 +19,7 @@
<script src="/src/i18n/strings.js"></script>
<script src="/src/vendor/system-csp-production.src.js"></script>
- <script src="/src/module-trampoline.js"></script>
+ <script src="/src/moduleTrampoline.js"></script>
<style>
.tree-item {
diff --git a/src/popup/popup.html b/src/popup/popup.html
index 30b11aaea..5800519a4 100644
--- a/src/popup/popup.html
+++ b/src/popup/popup.html
@@ -16,7 +16,7 @@
<script src="/src/i18n/strings.js"></script>
<script src="/src/vendor/system-csp-production.src.js"></script>
- <script src="/src/module-trampoline.js"></script>
+ <script src="/src/moduleTrampoline.js"></script>
</head>
<body>
diff --git a/src/wxBackend.ts b/src/wxBackend.ts
index ec6d95874..7893dd64d 100644
--- a/src/wxBackend.ts
+++ b/src/wxBackend.ts
@@ -425,7 +425,7 @@ function clearRateLimitCache() {
export function wxMain() {
window.onerror = (m, source, lineno, colno, error) => {
- logging.record("error", m + error, source || "(unknown)", lineno || 0, colno || 0);
+ logging.record("error", m + error, undefined, source || "(unknown)", lineno || 0, colno || 0);
}
chrome.browserAction.setBadgeText({ text: "" });
diff --git a/tsconfig.json b/tsconfig.json
index 76c024381..f504e41df 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -16,23 +16,24 @@
"src/checkable.ts",
"decl/lib.es6.d.ts",
"src/chromeBadge.ts",
- "src/cryptoApi-test.ts",
"decl/urijs/URIjs.d.ts",
+ "src/cryptoApi-test.ts",
"src/components.ts",
- "src/emscriptif-test.ts",
"decl/systemjs/systemjs.d.ts",
+ "src/emscriptif-test.ts",
"src/cryptoApi.ts",
- "src/helpers-test.ts",
"decl/react-global.d.ts",
+ "src/helpers-test.ts",
"src/cryptoLib.ts",
"src/types-test.ts",
"decl/chrome/chrome.d.ts",
- "src/wallet-test.ts",
"src/cryptoWorker.ts",
+ "src/wallet-test.ts",
"src/emscriptif.ts",
"src/helpers.ts",
"src/http.ts",
"src/logging.ts",
+ "src/moduleTrampoline.ts",
"src/query.ts",
"src/taler-wallet-lib.ts",
"src/types.ts",