Skip to content

Commit c645113

Browse files
committed
Rename reportError to logError, to match server & UI
This is primarily to avoid a confusing issue where it's not suggested as an import (or errored if not imported) due to a global type. I doubt that'll matter much here, since there's just not much code here, but using the same name everywhere is helpful.
1 parent 1ec76e6 commit c645113

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (!DEV_MODE) {
2121
});
2222
}
2323

24-
export function reportError(error: Error | string) {
24+
export function logError(error: Error | string) {
2525
console.log(error);
2626

2727
if (typeof error === 'string') {

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const DEV_MODE = process.env.HTK_DEV === 'true';
22

33
// Set up error handling before everything else:
4-
import { reportError, addBreadcrumb } from './errors';
4+
import { logError, addBreadcrumb } from './errors';
55

66
import { spawn, ChildProcess } from 'child_process';
77
import * as os from 'os';
@@ -162,7 +162,7 @@ if (!amMainInstance) {
162162
await stopServer(server, AUTH_TOKEN);
163163
} catch (error) {
164164
console.log('Failed to kill server', error);
165-
reportError(error);
165+
logError(error);
166166
} finally {
167167
// We've done our best - now shut down for real.
168168
app.quit();
@@ -225,7 +225,7 @@ if (!amMainInstance) {
225225
contents.on('render-process-gone', (_event, details) => {
226226
if (details.reason === 'clean-exit') return;
227227

228-
reportError(`Renderer gone: ${details.reason}`);
228+
logError(`Renderer gone: ${details.reason}`);
229229
showErrorAlert(
230230
"UI crashed",
231231
"The HTTP Toolkit UI stopped unexpected.\n\nPlease file an issue at github.com/httptoolkit/httptoolkit."
@@ -336,7 +336,7 @@ if (!amMainInstance) {
336336
)) {
337337
// If the folder contains something other than the expected version folders, be careful.
338338
console.log(serverPaths);
339-
reportError(
339+
logError(
340340
`Server path (${serverUpdatesPath}) contains unexpected content, ignoring`
341341
);
342342
return;
@@ -448,7 +448,7 @@ if (!amMainInstance) {
448448
}
449449

450450
addBreadcrumb({ category: 'server-exit', message: error.message, level: <any>'error', data: { serverRunTime } });
451-
reportError(error);
451+
logError(error);
452452

453453
showErrorAlert(
454454
'HTTP Toolkit hit an error',
@@ -539,7 +539,7 @@ if (!amMainInstance) {
539539
// Otherwise we just let Electron use the defaults - no problem at all.
540540
})
541541
.catch((e) => {
542-
reportError(e);
542+
logError(e);
543543
return undefined;
544544
});
545545

src/stop-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as ChildProcess from 'child_process';
22
import * as http from 'http';
33

4-
import { reportError } from './errors';
4+
import { logError } from './errors';
55
import { delay } from './util';
66

77
const isRunning = (pid: number) => {
@@ -16,7 +16,7 @@ const isRunning = (pid: number) => {
1616

1717
export async function stopServer(proc: ChildProcess.ChildProcess, token: string) {
1818
await softShutdown(token)
19-
.catch(reportError); // If that fails, continue shutting down anyway
19+
.catch(logError); // If that fails, continue shutting down anyway
2020

2121
// In each case, that triggers a clean shutdown. We want to make sure it definitely shuts
2222
// down though, so we poll the process state, and kill it if it's still running in 3 seconds.

0 commit comments

Comments
 (0)