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) {
|
||||
this._error = err;
|
||||
this._error = this._getErrorMessage(err);
|
||||
return;
|
||||
}
|
||||
let connection;
|
||||
try {
|
||||
connection = await createConnection({ auth });
|
||||
} catch (err) {
|
||||
this._error = err;
|
||||
this._error = this._getErrorMessage(err);
|
||||
return;
|
||||
}
|
||||
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() {
|
||||
const controls = document.body.querySelector("touch-controls");
|
||||
if (controls) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user