Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 72b2ebd

Browse files
committed
Add a way to submit debug logs for actual errors
Inspired by #8354
1 parent 2c247c9 commit 72b2ebd

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

src/components/views/messages/DateSeparator.tsx

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import SettingsStore from "../../../settings/SettingsStore";
2828
import { UIFeature } from "../../../settings/UIFeature";
2929
import Modal from "../../../Modal";
3030
import ErrorDialog from "../dialogs/ErrorDialog";
31+
import BugReportDialog from "../dialogs/BugReportDialog";
32+
import AccessibleButton from "../elements/AccessibleButton";
3133
import { contextMenuBelow } from "../rooms/RoomTile";
3234
import { ContextMenuTooltipButton } from "../../structures/ContextMenu";
3335
import IconizedContextMenu, {
@@ -160,17 +162,43 @@ export default class DateSeparator extends React.Component<IProps, IState> {
160162
const roomIdBeforeDisplayingError = SdkContextClass.instance.roomViewStore.getRoomId();
161163
if (roomIdBeforeDisplayingError === roomIdForJumpRequest) {
162164
let friendlyErrorMessage = `An error occured while trying to find and jump to the given date.`;
163-
if (err?.errcode === "M_NOT_FOUND") {
164-
friendlyErrorMessage = _t(
165-
"We were unable to find an event looking forwards from %(dateString)s. " +
166-
"Try choosing an earlier date.",
167-
{ dateString: formatFullDateNoDay(new Date(unixTimestamp)) },
168-
);
169-
}
165+
let submitDebugLogsContent: JSX.Element = <></>;
170166
if (err?.name === "ConnectionError") {
171-
friendlyErrorMessage = _t(
172-
"Your homeserver was unreachable and was not able to log you in. Please try again. " +
173-
"If this continues, please contact your homeserver administrator.",
167+
if (err?.errcode === "M_NOT_FOUND") {
168+
friendlyErrorMessage = _t(
169+
"We were unable to find an event looking forwards from %(dateString)s. " +
170+
"Try choosing an earlier date.",
171+
{ dateString: formatFullDateNoDay(new Date(unixTimestamp)) },
172+
);
173+
} else {
174+
friendlyErrorMessage = _t(
175+
"A network error occurred while trying to find and jump to the given date. " +
176+
"Your homeserver might be down or was just a temporary problem with your " +
177+
"internet connection. Please try again. If this continues, please " +
178+
"contact your homeserver administrator.",
179+
);
180+
}
181+
} else {
182+
// We only give the option to submit logs for actual errors, not network problems.
183+
submitDebugLogsContent = (
184+
<p>
185+
{_t(
186+
"Please submit <debugLogsLink>debug logs</debugLogsLink> to help us " +
187+
"track down the problem.",
188+
{},
189+
{
190+
debugLogsLink: (sub) => (
191+
<AccessibleButton
192+
kind="link"
193+
onClick={() => this.onBugReport(err)}
194+
data-testid="jump-to-date-error-submit-debug-logs-button"
195+
>
196+
{sub}
197+
</AccessibleButton>
198+
),
199+
},
200+
)}
201+
</p>
174202
);
175203
}
176204

@@ -179,6 +207,7 @@ export default class DateSeparator extends React.Component<IProps, IState> {
179207
description: (
180208
<>
181209
<p>{friendlyErrorMessage}</p>
210+
{submitDebugLogsContent}
182211
<details>
183212
<summary>{_t("Error details")}</summary>
184213

@@ -203,6 +232,13 @@ export default class DateSeparator extends React.Component<IProps, IState> {
203232
}
204233
};
205234

235+
private onBugReport = (err): void => {
236+
Modal.createDialog(BugReportDialog, {
237+
error: err,
238+
initialText: "Error occured while using jump to date #jump-to-date",
239+
});
240+
};
241+
206242
private onLastWeekClicked = (): void => {
207243
const date = new Date();
208244
date.setDate(date.getDate() - 7);

src/i18n/strings/en_EN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,9 +2351,12 @@
23512351
"Today": "Today",
23522352
"Yesterday": "Yesterday",
23532353
"We were unable to find an event looking forwards from %(dateString)s. Try choosing an earlier date.": "We were unable to find an event looking forwards from %(dateString)s. Try choosing an earlier date.",
2354+
"A network error occurred while trying to find and jump to the given date. Your homeserver might be down or was just a temporary problem with your internet connection. Please try again. If this continues, please contact your homeserver administrator.": "A network error occurred while trying to find and jump to the given date. Your homeserver might be down or was just a temporary problem with your internet connection. Please try again. If this continues, please contact your homeserver administrator.",
2355+
"Please submit <debugLogsLink>debug logs</debugLogsLink> to help us track down the problem.": "Please submit <debugLogsLink>debug logs</debugLogsLink> to help us track down the problem.",
23542356
"Unable to find event at that date": "Unable to find event at that date",
23552357
"Error details": "Error details",
23562358
"Request status code: %(statusCode)s": "Request status code: %(statusCode)s",
2359+
"HTTP status code not available": "HTTP status code not available",
23572360
"Error code: %(errorCode)s": "Error code: %(errorCode)s",
23582361
"Error code not available": "Error code not available",
23592362
"Last week": "Last week",

0 commit comments

Comments
 (0)