Skip to content

Commit f2cc9e1

Browse files
jellymartinpitt
authored andcommitted
shell: lib: handle cockpit.user() failures
In our test TestLogin.testFailingWebsocket the dbus calls fail which fails the promise which was unhandled leading to the tests to fail due to an unhandled exception.
1 parent 376bfeb commit f2cc9e1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pkg/lib/hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function usePageLocation() {
8888

8989
const cockpit_user_promise = cockpit.user();
9090
let cockpit_user = null;
91-
cockpit_user_promise.then(user => { cockpit_user = user });
91+
cockpit_user_promise.then(user => { cockpit_user = user }).catch(err => console.log(err));
9292

9393
export function useLoggedInUser() {
9494
const [user, setUser] = useState(cockpit_user);

pkg/shell/hosts.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class CockpitHosts extends React.Component {
7070
componentDidMount() {
7171
cockpit.user().then(user => {
7272
this.setState({ current_user: user.name || "" });
73-
});
73+
}).catch(exc => console.log(exc));
7474
}
7575

7676
static getDerivedStateFromProps(nextProps, prevState) {

pkg/shell/indexes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function MachinesIndex(index_options, machines, loader) {
9797
let current_user = "";
9898
cockpit.user().then(user => {
9999
current_user = user.name || "";
100-
});
100+
}).catch(exc => console.log(exc));
101101

102102
/* Navigation */
103103
let ready = false;

0 commit comments

Comments
 (0)