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.
This commit is contained in:
parent
376bfebb02
commit
f2cc9e1a36
|
@ -88,7 +88,7 @@ export function usePageLocation() {
|
|||
|
||||
const cockpit_user_promise = cockpit.user();
|
||||
let cockpit_user = null;
|
||||
cockpit_user_promise.then(user => { cockpit_user = user });
|
||||
cockpit_user_promise.then(user => { cockpit_user = user }).catch(err => console.log(err));
|
||||
|
||||
export function useLoggedInUser() {
|
||||
const [user, setUser] = useState(cockpit_user);
|
||||
|
|
|
@ -70,7 +70,7 @@ export class CockpitHosts extends React.Component {
|
|||
componentDidMount() {
|
||||
cockpit.user().then(user => {
|
||||
this.setState({ current_user: user.name || "" });
|
||||
});
|
||||
}).catch(exc => console.log(exc));
|
||||
}
|
||||
|
||||
static getDerivedStateFromProps(nextProps, prevState) {
|
||||
|
|
|
@ -97,7 +97,7 @@ function MachinesIndex(index_options, machines, loader) {
|
|||
let current_user = "";
|
||||
cockpit.user().then(user => {
|
||||
current_user = user.name || "";
|
||||
});
|
||||
}).catch(exc => console.log(exc));
|
||||
|
||||
/* Navigation */
|
||||
let ready = false;
|
||||
|
|
Loading…
Reference in New Issue