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

Friendly error messages with expanded content #771

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

sampottinger
Copy link
Collaborator

Superceeds #747, #748, and #749. This is for Google Summer of Code project on friendly error messages (see #741). This is led by @WillRabalais04.

@sampottinger
Copy link
Collaborator Author

Hey @WillRabalais04! You are doing a great job. I will leave some comments here for you to address before the end of GSoC. Thanks!

Copy link
Collaborator Author

@sampottinger sampottinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good @WillRabalais04. If needed, you can leave the language server for me after GSoC. However, if you can please address the others, that would be great. Thanks for all of your great work!

Thread thread;

public class friendlyErrorPopup{

private String messageText = "It looks like either a class name or semicolon is missing near 'asdfsda' on line 2!<br><br><b>Hint:</b> <br>Either a [class](https://processing.org/reference/class.html) was not given a name or a [semicolon](https://processing.org/reference/semicolon.html) is missing.<br><br><b>Suggestion:</b> <br>If the name was forgotten, add it and ensure that it does not start with a number. Make sure it only includes letters, numbers, dollar signs ($) and underscores (_). Also check that the name is not a keyword that is part of the language like \"true\", \"class\" or \"setup\" . If you are missing a semicolon, check the ends of the [statements](https://processing.org/examples/statementscomments.html) near 'if (' and line '43234234'.<br><br><b>For more:</b> [Variable Examples](https://processing.org/examples/variables.html)";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this will be changed out for the error message from the properties file.

private JFrame popupFrame;
final int PROCESSING_SAYS_OFFSET = 5;

String markdownToHtml(String target) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make this private? private String markdownToHtml(String target) {

Thread thread;

public class friendlyErrorPopup{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return html;
}

public friendlyErrorPopup(String messageText){
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. public FriendlyErrorPopup(String messageText) {


// allows for error messages with markdown links in the first line although there currently are none
while (linkSkipperMatcher.find()){

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider removing this empty line

if (message.contains("viable alternative")) {

// ST messageTemplate = new ST(getLocalStr("$statement$"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no longer needed, please remove this commented code.

localizations.put("editor.status.missing.name", "Missing name near %s?");
localizations.put("editor.status.missing.type", "Missing name or type near %s?");
localizations.put("editor.status.missing.default", "Missing '%s'?");
localizations.put("editor.status.error.syntax", "Syntax Error - TEST$statement$");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the inclusion of TEST was intentional.

@@ -20,19 +20,19 @@ public void setup() {

@Test
public void testPresent() {
Optional<PdeIssueEmitter.IssueMessageSimplification> msg = strategy.simplify(" int x =");
Optional<PdeIssueEmitter.IssueMessageSimplification> msg = strategy.simplify(" int x =", 123);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to update the other tests as well!

@@ -20,13 +20,13 @@ public void setup() {

@Test
public void testPresent() {
Optional<PdeIssueEmitter.IssueMessageSimplification> msg = strategy.simplify("test(a,01a");
Optional<PdeIssueEmitter.IssueMessageSimplification> msg = strategy.simplify("test(a,01a", 123);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for updating tests <3

editor.status.hiding_enclosing_type = The class “$statement$” cannot have the same name as your sketch or its enclosing class

editor.status.bad.assignment = There seems to be some trouble with how a variable is being assigned near line $linenumber$!<br><br><b>Hint:</b> <br>There is an issue with how a variable is being set to a certain value. This is also known as variable [assignment](https://processing.org/reference/assign.html). We suspect that the problem is near ‘$statement$’.<br><br><b>Suggestion:</b> <br>It’s important to double check that the variable is named properly (see the variable example below) and that you have included all of the necessary parts of a variable assignment. You should also make sure that you chose an appropriate [datatype](https://processing.org/reference/#data) for your variable so that it can hold the value that you are assigning to it.<br><br><b>Example:</b>To assign variables you need the type, name, assignment operator (=), the value you want to assign the variable to and a semicolon. Here’s the basic format:<br>[data type] [name] = [value]; <br><b>Example:</b> <br>int num = 4;<br><br>For more: [Variable Example](https://processing.org/examples/variables.html)
editor.status.bad.generic = It looks like something (a generic) was not given a type to hold near line $linenumber$ near $statement$.<br><br><b>Hint:</b><br>When we're working with things like lists or arrays in Processing, you need to tell it what type of data it will hold. It seems like you forgot to specify the type of data you're using somewhere near line$linenumber$.<br><br><b>Suggestion:</b><br>The syntax for informing Processing about the intended data type of a data structure involves the use of angle brackets ('<>') referred to as generics. Typically, these angle brackets are placed after the name of the data structure.<br><br><b>Example:</b><br>If you want to store integers in a list, you would declare it like this: List<Integer> myList = new ArrayList<Integer>();<br><br><b>For More:</b> [Example of Data Structure ArrayList that Uses Generics](https://processing.org/examples/arraylistclass.html)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great but please check the language server experience. If needed, can do this together. It's possible that the PdeAdapter will need to go up until the first <br> or newline.

@sampottinger
Copy link
Collaborator Author

Hey Will! Thanks for addressing those comments. This is exciting!

@sampottinger
Copy link
Collaborator Author

sampottinger commented Aug 28, 2023

Hey @WillRabalais04! This is great thanks. I can't believe today is your last day for GSoC! We really appreciate everything you did for us this summer. I know we still need to tackle message localization and potentially some related copy edits on our side before this can go in (that are outside the scope of your GSoC work) so I will leave this as draft until @SableRaf and I connect on that final piece. This is a fantastic contribution! Please let me know if there is anything else I can do as you finish up.

@WillRabalais04
Copy link
Contributor

WillRabalais04 commented Aug 28, 2023

Final Report GSoC'23


Project: Improving Friendly Error Messages
Student: Will Rabalais
Mentors: Sam Pottinger & Raphaël de Courville
Organization: Processing


Project Overview

The Friendly Error Messages for Processing project aimed to improve the way error messages are displayed to users, enhancing the debugging experience by providing concise yet informative error messages with context, external resources and line numbers when possible. The project is an addition to the existing Processing error message system, adding more extensive error messages so that it resembles the P5.js Friendly Error System (FES). The challenge was that error messages generated by the compiler and the Java Virtual Machine are often vague, full of jargon and inaccessible to new programmers. The primary objective was to explain the error while and presenting the underlying cause in a manner more beginner friendly. Moreover, these revamped error messages featured direct links to relevant documentation for a deeper understanding of the issues.

Features Added

  • Simplified Error Messages: The existing error messages were often cryptic and challenging to understand for new developers. This project simplified the error messages by breaking them down into digestible components while retaining the necessary technical information. These error messages are accessible when an error is triggered via a new button (ℹ️) as seen below.
  • Contextual Information: Alongside the error message itself, the enhanced popup displayed additional contextual information, such as the relevant code snippet, variable values, or function call stack. This contextual data aimed to provide developers with a clearer understanding of the error's origin.
  • Improvements to the debugger: Alternative regex for resolving issue#606  #729 (and Bugfix for Issue #606 #692)
  • External Links: The enhanced error message included external links to relevant Processing Reference documentation, tutorials, or community discussions, assisting developers in troubleshooting and resolving issues efficiently.

Libraries Used

  • Flexmark Library: Flexmark is a Java library used for parsing and rendering Markdown content. In this project, Flexmark was employed to convert markdown-formatted error descriptions into HTML for rendering within the popup.
  • StringTemplate Library: StringTemplate is a template engine that allows for dynamic generation of textual output. It was used to create error message templates capable of incorporating specific statements from the code that likely caused the error and line numbers.
  • Ant: Indirectly used, part of Processing's build system.
  • Swing: Used to extend the Processing Development Environment.

Screenshots

Screen Shot 2023-08-28 at 11 07 18 AM Screen Shot 2023-08-28 at 11 06 50 AM

What’s Left to Improve

  • Originally we had aimed to include features such as a translation engine that for the friendly errors and an error log however due to time constraints these were not implemented.
  • Expand test coverage
  • Verify language server support

What I Personally Learned

The biggest challenge for me was experiencing a large codebase for the first time. I found that it required a different mindset than a smaller project does. I was also exposed to new libraries, design patterns and development practices. Working collaboratively with tools such as Git was also relatively new to me and I believe that learning in collaborative environment in which people depended on me I learned quicker than I would have on my own.

@sampottinger
Copy link
Collaborator Author

Thanks @WillRabalais04! We can work with our various volunteer localizers to take care of localization and the language server after localization!

@sampottinger
Copy link
Collaborator Author

I also added your debugger fix to your final report! That's happily already in production shipped to thousands of developers <3

@sampottinger
Copy link
Collaborator Author

Sorry @WillRabalais04 also added ant and swing to your library list.

@WillRabalais04
Copy link
Contributor

Hey @WillRabalais04! This is great thanks. I can't believe today is your last day for GSoC! We really appreciate everything you did for us this summer. I know we still need to tackle message localization and potentially some related copy edits on our side before this can go in (that are outside the scope of your GSoC work) so I will leave this as draft until @SableRaf and I connect on that final piece. This is a fantastic contribution! Please let me know if there is anything else I can do as you finish up.

It was great working with you and @SableRaf! It's great to know that this is going to be maintained after the GSoC period is over and I'm happy to keep contributing.

@WillRabalais04
Copy link
Contributor

I also added your debugger fix to your final report! That's happily already in production shipped to thousands of developers <3

Awesome!

@sampottinger sampottinger marked this pull request as ready for review September 27, 2023 00:05
@sneha9231
Copy link

hey, is the issue is still open? i want to contribute in it

@sushant705
Copy link

is the issue still open?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants