Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages and special case macOS compatibility error #725

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/api/tmc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,15 @@ export default class TMC {
if (timeout) {
clearTimeout(timeout);
}
if ("errno" in error) {
// check for macos error code -88
// which indicates an architecture mismatch
if (error.errno === -88) {
error.message = `A compatibility error was detected.
If you're on macOS: Try installing Rosetta by running \`softwareupdate --install-rosetta\` in the terminal. (See https://support.apple.com/en-us/102527).
${error.message}`;
}
}
reject(error);
});
cprocess.stderr.on("data", (chunk) => {
Expand Down
20 changes: 12 additions & 8 deletions src/panels/TmcPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ export class TmcPanel {
const organizations = await actionContext.tmc.getOrganizations();
if (organizations.err) {
actionContext.dialog.errorNotification(
`Failed to open panel: ${organizations.err}`,
"Failed to open panel.",
organizations.val,
);
return;
}
Expand All @@ -423,7 +424,8 @@ export class TmcPanel {
const courses = await actionContext.tmc.getCourses(organization.slug);
if (courses.err) {
actionContext.dialog.errorNotification(
`Failed to open panel: ${courses.err}`,
"Failed to open panel.",
courses.val,
);
return;
}
Expand All @@ -444,7 +446,8 @@ export class TmcPanel {
const organizations = await actionContext.tmc.getOrganizations();
if (organizations.err) {
actionContext.dialog.errorNotification(
`Failed to open panel: ${organizations.err}`,
"Failed to open panel.",
organizations.val,
);
return;
}
Expand Down Expand Up @@ -590,8 +593,8 @@ export class TmcPanel {
await actionContext.tmc.listLocalCourseExercises(message.courseName);
if (localCourseExercises.err) {
actionContext.dialog.errorNotification(
`Error trying to list local exercises while opening selected exercises. \
${localCourseExercises.val}`,
"Error trying to list local exercises while opening selected exercises.",
localCourseExercises.val,
);
return;
}
Expand Down Expand Up @@ -643,7 +646,7 @@ export class TmcPanel {
const updateResult = await updateCourse(actionContext, courseId);
if (updateResult.err) {
actionContext.dialog.errorNotification(
`Failed to update course: ${updateResult.val.message}`,
"Failed to update course.",
updateResult.val,
);
}
Expand Down Expand Up @@ -675,7 +678,8 @@ export class TmcPanel {
);
if (result.err) {
actionContext.dialog.errorNotification(
`Failed to add new course: ${result.val.message}`,
"Failed to add new course.",
result.val,
);
}
postMessageToWebview(webview, {
Expand Down Expand Up @@ -736,7 +740,7 @@ export class TmcPanel {
);
if (pasteResult.err) {
actionContext.dialog.errorNotification(
`Failed to send to TMC Paste: ${pasteResult.val.message}.`,
"Failed to send to TMC Paste.",
pasteResult.val,
);
TmcPanel.postMessage({
Expand Down
Loading