Skip to content

Commit

Permalink
Improve error messages and special case macOS compatibility error
Browse files Browse the repository at this point in the history
  • Loading branch information
Heliozoa committed Sep 25, 2024
1 parent 55f890b commit 26441dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
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

0 comments on commit 26441dc

Please sign in to comment.