Skip to content

Commit

Permalink
💻 Merge first line of error messages with details (hedyorg#5939)
Browse files Browse the repository at this point in the history
Refactors the first line of error messages. When the caption doesn't add  anything it removes it, and when it does, its shown in the details of the error message.

These are the new error messages:

Connection_error
![image](https://github.com/user-attachments/assets/c90dc8c6-4d6c-40d4-8b36-122e2f3857d0)


Execute_error
![image](https://github.com/user-attachments/assets/3c6732d1-d0cb-45ba-bf20-086702b2449e)

Other_error
![image](https://github.com/user-attachments/assets/0528d421-0911-406d-832a-feb1bda784d3)

Transpile_error This was entirely removed
![image](https://github.com/user-attachments/assets/3efca220-173f-48ed-9ada-c49c8db8376e)

Warning: removed as well
![image](https://github.com/user-attachments/assets/7e27df20-652d-401c-b6ee-7e1614730f9a)


Fixes hedyorg#4729 
**How to test**




Co-Authored-By: Felienne <[email protected]>
  • Loading branch information
jpelay and Felienne authored Nov 22, 2024
1 parent 3b282b8 commit d20eea0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 1,952 deletions.
1,912 changes: 0 additions & 1,912 deletions static/js/app-main.ts

This file was deleted.

10 changes: 5 additions & 5 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ export async function runit(level: number, lang: string, raw: boolean, disabled_
console.log('Response', response);
if (response.Warning && $('#editor').is(":visible")) {
//storeFixedCode(response, level);
error.showWarning(ClientMessages['Transpile_warning'], response.Warning);
error.showWarning(response.Warning);
}


Expand All @@ -593,7 +593,7 @@ export async function runit(level: number, lang: string, raw: boolean, disabled_
}

if (response.Error) {
error.show(ClientMessages['Transpile_error'], response.Error);
error.show("", response.Error);
if (response.Location && response.Location[0] != "?") {
//storeFixedCode(response, level);
// Location can be either [row, col] or just [row].
Expand Down Expand Up @@ -881,7 +881,7 @@ export function runPythonProgram(this: any, code: string, sourceMap: any, hasTur

// Only show the warning box for the first error shown
if (skip_faulty_found_errors && !warning_box_shown) {
error.showFadingWarning(ClientMessages['Execute_error'], ClientMessages['Errors_found']);
error.showFadingWarning(ClientMessages['Errors_found']);
warning_box_shown = true;
}
}
Expand Down Expand Up @@ -1044,7 +1044,7 @@ export function runPythonProgram(this: any, code: string, sourceMap: any, hasTur

// Check if the program was correct but the output window is empty: Return a warning
if ((!hasClear) && $('#output').is(':empty') && $('#turtlecanvas').is(':empty') && !hasMusic) {
error.showWarning(ClientMessages['Transpile_warning'], ClientMessages['Empty_output']);
error.showWarning(ClientMessages['Empty_output']);
return;
}
if (!hasWarnings && code !== last_code) {
Expand Down Expand Up @@ -1502,7 +1502,7 @@ export async function tryCatchErrorBox(cb: () => void | Promise<void>) {
return await cb();
} catch (e: any) {
console.log('Error', e);
error.show(ClientMessages['Transpile_error'], e.message);
error.show("", e.message);
}
}

Expand Down
22 changes: 10 additions & 12 deletions static/js/appbundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -63279,19 +63279,17 @@ ${o3}` : i3;
$("#errorbox").hide();
$("#warningbox").hide();
},
showWarning(caption, message) {
showWarning(message) {
this.hide();
$("#warningbox .caption").text(caption);
$("#warningbox .details").text(message);
$("#warningbox").show();
},
show(caption, message) {
$("#errorbox .caption").text(caption);
$("#errorbox .details").html(message);
$("#errorbox .details").html(caption + " " + message);
$("#errorbox").show();
},
showFadingWarning(caption, message) {
error.showWarning(caption, message);
showFadingWarning(message) {
error.showWarning(message);
setTimeout(function() {
$("#warningbox").fadeOut();
}, 1e4);
Expand Down Expand Up @@ -101981,7 +101979,7 @@ def note_with_error(value, err):
} else {
let mapError = theGlobalSourcemap[index3];
error.hide();
error.show(ClientMessages["Transpile_error"], mapError.error);
error.show("", mapError.error);
}
}
};
Expand Down Expand Up @@ -120977,14 +120975,14 @@ def note_with_error(value, err):
program_data = response;
console.log("Response", response);
if (response.Warning && $("#editor").is(":visible")) {
error.showWarning(ClientMessages["Transpile_warning"], response.Warning);
error.showWarning(response.Warning);
}
if (adventure && response.save_info) {
adventure.save_info = response.save_info;
adventure.editor_contents = code;
}
if (response.Error) {
error.show(ClientMessages["Transpile_error"], response.Error);
error.show("", response.Error);
if (response.Location && response.Location[0] != "?") {
theGlobalEditor.highlightError(response.Location[0], response.Location[1]);
}
Expand Down Expand Up @@ -121213,7 +121211,7 @@ def note_with_error(value, err):
theGlobalEditor.setIncorrectLine(range10, Number(index3));
}
if (skip_faulty_found_errors && !warning_box_shown) {
error.showFadingWarning(ClientMessages["Execute_error"], ClientMessages["Errors_found"]);
error.showFadingWarning(ClientMessages["Errors_found"]);
warning_box_shown = true;
}
}
Expand Down Expand Up @@ -121338,7 +121336,7 @@ def note_with_error(value, err):
$("#save_files_container").show();
}
if (!hasClear && $("#output").is(":empty") && $("#turtlecanvas").is(":empty") && !hasMusic) {
error.showWarning(ClientMessages["Transpile_warning"], ClientMessages["Empty_output"]);
error.showWarning(ClientMessages["Empty_output"]);
return;
}
if (!hasWarnings && code !== last_code) {
Expand Down Expand Up @@ -121683,7 +121681,7 @@ def note_with_error(value, err):
return await cb2();
} catch (e) {
console.log("Error", e);
error.show(ClientMessages["Transpile_error"], e.message);
error.show("", e.message);
}
}
function toggle_keyword_language(current_lang, new_lang) {
Expand Down
4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions static/js/cm-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { languagePerLevel } from "./lezer-parsers/language-packages";
import { theGlobalSourcemap, theLevel } from "./app";
import { monokai } from "./cm-monokai-theme";
import { error } from "./modal";
import { ClientMessages } from "./client-messages";
import { Tag, styleTags, tags as t } from "@lezer/highlight";


Expand Down Expand Up @@ -522,7 +521,7 @@ export class HedyCodeMirrorEditor implements HedyEditor {
// Show error for this line
let mapError = theGlobalSourcemap[index];
error.hide();
error.show(ClientMessages['Transpile_error'], mapError.error);
error.show("", mapError.error);
}
}
}
10 changes: 4 additions & 6 deletions static/js/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,19 @@ export const error = {
$('#errorbox').hide();
$('#warningbox').hide();
},
showWarning(caption: string, message: string) {
showWarning(message: string) {
this.hide();
$('#warningbox .caption').text(caption);
$('#warningbox .details').text(message);
$('#warningbox').show();
},

show(caption: string, message: string) {
$('#errorbox .caption').text(caption);
$('#errorbox .details').html(message);
$('#errorbox .details').html(caption + " " + message);
$('#errorbox').show();
},

showFadingWarning(caption: string, message: string) {
error.showWarning(caption, message);
showFadingWarning(message: string) {
error.showWarning(message);
setTimeout(function(){
$('#warningbox').fadeOut();
}, 10000);
Expand Down
4 changes: 1 addition & 3 deletions templates/embedded-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
style="display: none;">
<p class="close-dialog" onclick="hedyApp.error.hide ()"><i class="fa-solid fa-xmark"></i></p>
<div class="flex">
<div class="py-1">
<div class="py-1 flex items-center">
<svg class="fill-current h-6 w-6 text-red-500 ltr:mr-4 rtl:ml-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path
d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z" />
</svg>
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm" data-cy="error_details">An error occurred.</p>
</div>
</div>
Expand All @@ -53,7 +52,6 @@
</div>
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm">An error occurred.</p>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions templates/hedy-page/editor-and-output.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
style="display: none;">
<p class="close-dialog" onclick="hedyApp.error.hide ()"><i class="fa-solid fa-xmark"></i></p>
<div class="flex">
<div class="py-1">
<div class="py-1 flex items-center">
<svg class="fill-current h-6 w-6 text-red-500 ltr:mr-4 rtl:ml-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path
d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z" />
</svg>
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm" data-cy="error_details">An error occurred.</p>
</div>
</div>
Expand All @@ -52,7 +51,7 @@
role="alert" style="display: none;">
<p data-cy="close_warning" class="close-dialog" onclick="hedyApp.error.hide ()"><i class="fa-solid fa-xmark"></i></p>
<div class="flex">
<div class="py-1">
<div class="py-1 flex items-center">
<div id="warningbox_icon">
<svg class="fill-current h-6 w-6 text-yellow-500 ltr:mr-4 rtl:ml-4" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20">
Expand All @@ -61,7 +60,6 @@
</div>
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm">An error occurred.</p>
</div>
</div>
Expand Down
10 changes: 4 additions & 6 deletions templates/incl/editor-and-output.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@
style="display: none;">
<p class="close-dialog" onclick="hedyApp.error.hide ()"><i class="fa-solid fa-xmark"></i></p>
<div class="flex">
<div class="py-1">
<div class="py-1 flex items-center">
<svg class="fill-current h-6 w-6 text-red-500 ltr:mr-4 rtl:ml-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path
d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z" />
</svg>
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm" data-cy="error_details">An error occurred.</p>
<div>
<p class="details text-sm mt-2" data-cy="error_details">An error occurred.</p>
</div>
</div>
</div>
Expand All @@ -58,7 +57,7 @@
role="alert" style="display: none;">
<p class="close-dialog" onclick="hedyApp.error.hide ()"><i class="fa-solid fa-xmark"></i></p>
<div class="flex">
<div class="py-1">
<div class="py-1 flex items-center">
<div id="warningbox_icon">
<svg class="fill-current h-6 w-6 text-yellow-500 ltr:mr-4 rtl:ml-4" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20">
Expand All @@ -67,7 +66,6 @@
</div>
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm">An error occurred.</p>
</div>
</div>
Expand Down

0 comments on commit d20eea0

Please sign in to comment.