lib/client: use Error objects for error events
This commit is contained in:
parent
f9ec578fce
commit
31b293fa03
2 changed files with 31 additions and 24 deletions
|
@ -317,8 +317,21 @@ export default class App extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
showError(msg) {
|
||||
this.setState({ error: String(msg) });
|
||||
showError(err) {
|
||||
console.error("App error: ", err);
|
||||
|
||||
let text;
|
||||
if (err instanceof Error) {
|
||||
let l = [];
|
||||
while (err) {
|
||||
l.push(err.message);
|
||||
err = err.cause;
|
||||
}
|
||||
text = l.join(": ");
|
||||
} else {
|
||||
text = String(err);
|
||||
}
|
||||
this.setState({ error: text });
|
||||
lastErrorID++;
|
||||
return lastErrorID;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue