mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Cast: Show error message instead of number (#3752)
* Cast: Show error message instead of number * Update hc-main.ts
This commit is contained in:
parent
0bfc61629e
commit
b6fbf4da3a
@ -137,14 +137,14 @@ export class HcMain extends HassElement {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this._error = err;
|
this._error = this._getErrorMessage(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let connection;
|
let connection;
|
||||||
try {
|
try {
|
||||||
connection = await createConnection({ auth });
|
connection = await createConnection({ auth });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this._error = err;
|
this._error = this._getErrorMessage(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.hass) {
|
if (this.hass) {
|
||||||
@ -213,6 +213,23 @@ export class HcMain extends HassElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getErrorMessage(error: number): string {
|
||||||
|
switch (error) {
|
||||||
|
case 1:
|
||||||
|
return "Unable to connect to the Home Assistant websocket API.";
|
||||||
|
case 2:
|
||||||
|
return "The supplied authentication is invalid.";
|
||||||
|
case 3:
|
||||||
|
return "The connection to Home Assistant was lost.";
|
||||||
|
case 4:
|
||||||
|
return "Missing hassUrl. This is required.";
|
||||||
|
case 5:
|
||||||
|
return "Home Assistant needs to be served over https:// to use with Home Assistant Cast.";
|
||||||
|
default:
|
||||||
|
return "Unknown Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _breakFree() {
|
private _breakFree() {
|
||||||
const controls = document.body.querySelector("touch-controls");
|
const controls = document.body.querySelector("touch-controls");
|
||||||
if (controls) {
|
if (controls) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user