Skip to content

Commit eb515ca

Browse files
committed
Rename reportError to logError to avoid new global type
There's a relatively recent addition to the DOM global types, due to a real method available for web workers, which means it's very very easy to accidentally call reportError without importing it, which fails everywhere except web workers, where it merely does completely the wrong thing. logError is exactly the same, but without that problem.
1 parent 96dfd11 commit eb515ca

23 files changed

+62
-62
lines changed

src/components/common/copy-button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22

33
import { Icon } from "../../icons";
44
import { styled } from '../../styles';
5-
import { reportError } from '../../errors';
5+
import { logError } from '../../errors';
66

77
import { clickOnEnter } from '../component-utils';
88
import { PillButton } from './pill';
@@ -92,6 +92,6 @@ async function copyToClipboard(content: string) {
9292
await navigator.clipboard!.writeText(content);
9393
} catch (e) {
9494
console.log('Failed to copy to the clipboard');
95-
reportError(e);
95+
logError(e);
9696
}
9797
}

src/components/editor/base-editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { SchemaObject } from 'openapi-directory';
88
import type * as monacoTypes from 'monaco-editor';
99
import type { default as _MonacoEditor, MonacoEditorProps } from 'react-monaco-editor';
1010

11-
import { reportError } from '../../errors';
11+
import { logError } from '../../errors';
1212
import { delay } from '../../util/promise';
1313
import { asError } from '../../util/error';
1414
import { Omit } from '../../types';
@@ -358,7 +358,7 @@ export class BaseEditor extends React.Component<EditorProps> {
358358

359359
render() {
360360
if (!this.monacoEditorLoaded || !MonacoEditor) {
361-
reportError('Monaco editor failed to load');
361+
logError('Monaco editor failed to load');
362362
return null;
363363
}
364364

src/components/intercept/config/android-device-config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010

1111
import { styled } from '../../../styles';
1212
import { stringToBuffer } from '../../../util';
13-
import { reportError } from '../../../errors';
13+
import { logError } from '../../../errors';
1414

1515
import { Interceptor } from '../../../model/interception/interceptors';
1616
import { ProxyStore } from '../../../model/proxy-store';
@@ -149,7 +149,7 @@ class AndroidConfig extends React.Component<{
149149
"\n\n" +
150150
"Please open an issue at github.com/httptoolkit/httptoolkit"
151151
);
152-
reportError("Android QR activation failed - no network addresses");
152+
logError("Android QR activation failed - no network addresses");
153153
this.props.closeSelf();
154154
}
155155
});

src/components/intercept/config/electron-config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { observer, inject } from 'mobx-react';
44

55
import { styled } from '../../../styles';
66
import { Icon } from '../../../icons';
7-
import { reportError } from '../../../errors';
7+
import { logError } from '../../../errors';
88

99
import { Interceptor } from '../../../model/interception/interceptors';
1010
import { UiStore } from '../../../model/ui-store';
@@ -176,7 +176,7 @@ class ElectronConfig extends React.Component<{
176176
reportSuccess();
177177
}).catch((e) => {
178178
this.props.uiStore!.forgetElectronPath(pathToApplication);
179-
reportError(e);
179+
logError(e);
180180
});
181181
}
182182

src/components/intercept/intercept-option.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { observer, inject } from 'mobx-react';
66
import { NARROW_LAYOUT_BREAKPOINT, styled } from '../../styles';
77
import { Icon } from '../../icons';
88
import { trackEvent } from '../../metrics';
9-
import { reportError } from '../../errors';
9+
import { logError } from '../../errors';
1010
import { windowSize } from '../../util/ui';
1111

1212
import { Interceptor } from '../../model/interception/interceptors';
@@ -324,7 +324,7 @@ export class InterceptOption extends React.Component<InterceptOptionProps> {
324324
onActivationStarted();
325325
activateInterceptor(interceptor.activationOptions)
326326
.then(() => onActivationSuccessful())
327-
.catch((e) => reportError(e));
327+
.catch((e) => logError(e));
328328
}
329329
}
330330

src/components/mock/mock-page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as dateFns from 'date-fns';
77
import { styled } from '../../styles';
88
import { WithInjected } from '../../types';
99
import { Icon } from '../../icons';
10-
import { reportError } from '../../errors';
10+
import { logError } from '../../errors';
1111
import { uploadFile, saveFile } from '../../util/ui';
1212

1313
import { RulesStore } from '../../model/rules/rules-store';
@@ -332,7 +332,7 @@ class MockPage extends React.Component<MockPageProps> {
332332
JSON.parse(uploadedFile)
333333
);
334334
} catch (e) {
335-
reportError(e);
335+
logError(e);
336336
alert(`Rules could not be imported: ${e}`);
337337
}
338338
}

src/components/view/http/http-details-pane.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as portals from 'react-reverse-portal';
66

77
import { CollectedEvent, HtkResponse, HttpExchange } from '../../../types';
88
import { styled } from '../../../styles';
9-
import { reportError } from '../../../errors';
9+
import { logError } from '../../../errors';
1010

1111
import { UiStore } from '../../../model/ui-store';
1212
import { RulesStore } from '../../../model/rules/rules-store';
@@ -229,7 +229,7 @@ export class HttpDetailsPane extends React.Component<{
229229
) {
230230
return this.renderWebSocketMessages(exchange);
231231
} else {
232-
reportError(`Expanded ${expandedCard}, but can't show anything`);
232+
logError(`Expanded ${expandedCard}, but can't show anything`);
233233
return null; // Shouldn't ever happen, unless we get into a funky broken state
234234
}
235235
}

src/components/view/http/http-error-header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import * as semver from 'semver';
33

44
import { WarningIcon } from '../../../icons';
5-
import { reportError } from '../../../errors';
5+
import { logError } from '../../../errors';
66

77
import { desktopVersion, versionSatisfies, DESKTOP_HEADER_LIMIT_CONFIGURABLE } from '../../../services/service-versions';
88

@@ -110,7 +110,7 @@ export function tagsToErrorType(tags: string[]): ErrorType | undefined {
110110
tags.filter(t => t.startsWith("passthrough-error:")).length > 0 ||
111111
tags.filter(t => t.startsWith("client-error:")).length > 0
112112
) {
113-
reportError(`Unrecognized error tag ${JSON.stringify(tags)}`);
113+
logError(`Unrecognized error tag ${JSON.stringify(tags)}`);
114114
return 'unknown';
115115
}
116116
}

src/components/view/http/http-export-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Omit, HttpExchange } from '../../../types';
1010
import { styled } from '../../../styles';
1111
import { Icon } from '../../../icons';
1212
import { saveFile } from '../../../util/ui';
13-
import { reportError } from '../../../errors';
13+
import { logError } from '../../../errors';
1414

1515
import { AccountStore } from '../../../model/account/account-store';
1616
import { UiStore } from '../../../model/ui-store';
@@ -142,7 +142,7 @@ const ExportSnippetEditor = observer((p: {
142142
snippet = new HTTPSnippet(harSnippetBase).convert(target, client);
143143
} catch (e) {
144144
console.log(`Failed to export request for ${target}--${client}`);
145-
reportError(e);
145+
logError(e);
146146
snippet = dedent`
147147
Could not generate a snippet for this request
148148

src/components/view/view-event-list-buttons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { saveFile, uploadFile, Ctrl } from '../../util/ui';
1010
import { AccountStore } from '../../model/account/account-store';
1111
import { EventsStore } from '../../model/events/events-store';
1212
import { generateHar } from '../../model/http/har';
13-
import { reportError } from '../../errors';
13+
import { logError } from '../../errors';
1414
import { formatAjvError } from '../../util/json-schema';
1515

1616
import { IconButton } from '../common/icon-button';
@@ -83,7 +83,7 @@ export const ImportHarButton = inject('eventsStore', 'accountStore')(
8383
data = JSON.parse(uploadedFile);
8484
await props.eventsStore!.loadFromHar(data);
8585
} catch (error: any) {
86-
reportError(error);
86+
logError(error);
8787

8888
if (error.name === 'HARError' && error.errors) {
8989
alert(dedent`

0 commit comments

Comments
 (0)