mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-12 15:33:22 -05:00
upgrade typescript to 4.5.5
I found one significant breaking change: caught exceptions are now unknown rather than any. Rework the error handling a bit to match.
This commit is contained in:
parent
a82453e73a
commit
274dc09ec3
1127
ui/package-lock.json
generated
1127
ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,8 +21,8 @@
|
|||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-router-dom": "^6.2.1",
|
"react-router-dom": "^6.2.1",
|
||||||
"react-scripts": "5.0.0",
|
"react-scripts": "^5.0.0",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "4.5.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
@ -121,11 +121,14 @@ class LiveCameraDriver {
|
|||||||
console.error(`${this.camera.shortName}: ws error`);
|
console.error(`${this.camera.shortName}: ws error`);
|
||||||
};
|
};
|
||||||
|
|
||||||
onWsMessage = async (e: MessageEvent) => {
|
onWsMessage = async (e: MessageEvent<Blob>) => {
|
||||||
let raw;
|
let raw;
|
||||||
try {
|
try {
|
||||||
raw = new Uint8Array(await e.data.arrayBuffer());
|
raw = new Uint8Array(await e.data.arrayBuffer());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof DOMException)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
this.error(`error reading part: ${e.message}`);
|
this.error(`error reading part: ${e.message}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -135,7 +138,7 @@ class LiveCameraDriver {
|
|||||||
}
|
}
|
||||||
let result = parsePart(raw);
|
let result = parsePart(raw);
|
||||||
if (result.status === "error") {
|
if (result.status === "error") {
|
||||||
this.error("unparseable part");
|
this.error(`unparseable part: ${result.errorMessage}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const part = result.part;
|
const part = result.part;
|
||||||
@ -223,6 +226,9 @@ class LiveCameraDriver {
|
|||||||
try {
|
try {
|
||||||
buf.srcBuf.appendBuffer(part.body);
|
buf.srcBuf.appendBuffer(part.body);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof DOMException)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
// In particular, appendBuffer can throw QuotaExceededError.
|
// In particular, appendBuffer can throw QuotaExceededError.
|
||||||
// <https://developers.google.com/web/updates/2017/10/quotaexceedederror>
|
// <https://developers.google.com/web/updates/2017/10/quotaexceedederror>
|
||||||
// tryTrimBuffer removes already-played stuff from the buffer to avoid
|
// tryTrimBuffer removes already-played stuff from the buffer to avoid
|
||||||
|
@ -42,6 +42,9 @@ async function myfetch(
|
|||||||
try {
|
try {
|
||||||
response = await fetch(url, init);
|
response = await fetch(url, init);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof DOMException)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
if (e.name === "AbortError") {
|
if (e.name === "AbortError") {
|
||||||
return { status: "aborted" };
|
return { status: "aborted" };
|
||||||
} else {
|
} else {
|
||||||
@ -56,6 +59,9 @@ async function myfetch(
|
|||||||
try {
|
try {
|
||||||
text = await response.text();
|
text = await response.text();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof DOMException)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
console.warn(
|
console.warn(
|
||||||
`${url}: ${response.status}: unable to read body: ${e.message}`
|
`${url}: ${response.status}: unable to read body: ${e.message}`
|
||||||
);
|
);
|
||||||
@ -105,6 +111,9 @@ export async function init(
|
|||||||
try {
|
try {
|
||||||
body = await fetchRes.response.arrayBuffer();
|
body = await fetchRes.response.arrayBuffer();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof DOMException)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
console.warn(`${url}: unable to read body: ${e.message}`);
|
console.warn(`${url}: unable to read body: ${e.message}`);
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
@ -130,6 +139,9 @@ async function json<T>(
|
|||||||
try {
|
try {
|
||||||
body = await fetchRes.response.json();
|
body = await fetchRes.response.json();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof DOMException)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
console.warn(`${url}: unable to read body: ${e.message}`);
|
console.warn(`${url}: unable to read body: ${e.message}`);
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
|
Loading…
Reference in New Issue
Block a user