processing / processing/processing4

Improving Processing Error Messages

Đang mở
#741 10 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Java
Star
494
Fork
183
Merge trung bình
4 giờ 39 phút
Pull request đã merge (30 ngày)
3

Mô tả

Created by: WillRabalais04

Processing Friendly Errors

We are building out friendly error message rewriting by extending the PreprocessIssueMessageSimplifier. To determine which errors to support, we worked with Raphaël and Sam to run a community survey.

Motivations

The results of the survey showed that although the error messages are usable, with an average clarity rating of 3.32 out of 5 there is room for improvement. The key elements that respondents identified as crucial for understanding error messages include the name and type of the error, specifics about what broke in the code, traceback to the specific line of the error, expected versus found outcomes, resources for contextualization and guidance, and possible solutions. Enhancing error messages based on the insights of the survey would greatly benefit the Processing user experience for beginners and advanced users alike. We hope to foster better understanding and more efficient problem-solving.

Currently Simplified Errors to Improve On

Strategy Current Error Output Acknowledged In Survey URL
InvalidIdentifierStrategy Bad identifier? Did you forget a variable or start an identifier with digits near ‘statement’ Variables
OR
Variable Examples, Identifiers,
Keywords
&
Statements
MismatchedInputSimplifierStrategy Missing operator, semicolon, or ‘}’ near ‘statement’ Operators,
Operators Example,
Semicolons,
Curly Braces
&
Statements
InvalidAssignmentStrategy Possible error on variable assignment near ‘statement’ Variables
OR
Variable Examples,
Assignment Operator
&
Statements
VariableDeclarationMissingTypeStrategy Missing name or ; or type near ‘statement’ Variables
OR
Variable Examples,
Semicolons,
Identifiers
&
Statements
MissingCurlyAtStartSimplifierStrategy Missing left curly bracket “{” Curly Braces
MissingCurlyAtSemicolonSimplifierStrategy Missing right curly bracket “}” Curly Braces
UnbalancedChevStrategy Missing '<' OR Missing '>' Generics,
Generic Methods
&
Generics & Subtyping
InvalidGenericDefinitionStrategy Possibly missing type in generic near ‘statement’ Generics,
Generic Methods,
Statements
&
Generics & Subtyping
MissingIdentifierSimplifierStrategy Missing name or ; near ‘statement’ Identifiers
&
Statements
KnownMissingSimplifierStrategy Missing “statement” Statements
ExtraneousInputSimplifierStrategy ArithmeticException statement or extra code near ‘statement’ Arithmetic Exceptions,
Operator Precedence
&
Statements
MissingClassNameStrategy Missing name or ; near ‘statement’ Classes ,
Identifiers,
Semicolons
&
Statements
MethodMissingNameStrategy Missing name or ; near ‘statement’ Methods,
Identifiers,
Semicolons
&
Statements
ErrorOnParameterStrategy Error on parameter or method declaration near ‘statement’ Parameters,
Methods
&
Statements
MissingSingleQuoteStrategy Missing “'” Chars
MissingDoubleQuoteStrategy Missing “"” Strings
UnbalancedCurlyStrategy Missing "{" OR Missing "}" Curly Braces
UnbalancedParenStrategy Missing "(" OR Missing ")" Parentheses
DefaultMessageSimplifier
  • Error
  • Error on variable assignment near 'statement'
  • Identifier cannot start with digits near 'statement'
  • Error on parameter or method declaration near 'statement'
  • Unexpected extra code near 'statement'
  • Missing operator or semicolon near 'statement'
  • Missing name near 'statement'
  • Missing name or type near 'statement'
  • Missing 'statement'
  • Missing '}'
  • Missing '{'
n/a TBD

Errors to Add Strategies For

Priority Error
First
  • ArrayIndexOutOfBoundException
  • NullPointerException
  • UnsupportedOperationException
  • NumberFormatException
  • StackOverflowError
  • IndexOutOfBoundsException
  • StringIndexOutOfBoundsException
Secondary
  • ClassCastException
  • IllegalThreadStateException
  • IllegalStateException
  • ArrayStoreException
  • NoSuchMethodError
TBD
  • FileNotFoundException
  • IOException
  • ConcurrentModificationException
  • EnumConstantNotPresentException

Unsupported Errors

The following will still operate as usual without rewriting / error simplification.

  • Variable is named after keyword
  • GLSL/Shader errors
  • Compatibility issues with Android extensions
  • Library errors
  • Python errors
  • p5.js errors

Error Message Template

Optional? Feature
Processing found an error type error at [error line](link moves cursor to line number)!
[error context]
[reminder / additional context] OR We expected [expectation] but found [x]!
We suggest [hint]!
+ More Info on:
-[additional resources]
▶Click to See Original Error! [Toggles Original Error] *

* The toggle to see the original error will be added at some point but likely will not be in the first version of the improved error messages as it may be difficult to implement.

Example 1: Array Index Out of Bound Exception

🔵 Processing says: Oops! It looks like you're trying to look at an item in your 'numbers' array that doesn't exist. (On line 3 in sketch_230707c.pde)

Remember, counting in Processing starts from 0, not 1. This means your 'numbers' array, which has 3 items, has positions labelled from 0 to 2. If you're trying to find an item at position 3 and above (or below 0), it won't work because there's no item there!
To fix this, make sure you're looking at positions that exist in your 'numbers' array, that is, positions from 0 to 2.

For more:https://processing.org/examples/array.html

Example 2: Invalid Identifier

🔵 Processing says: Uh-oh! There's an issue with a "bad identifier" in your code. Specifically, the issue is with 'int 9'. (On line 48 in sketch_230710a.pde)

In Processing, identifiers (like variable names, function names, etc.) can not start with a number and should only include letters, numbers, or underscores. Therefore, '9' is not a valid name.

Here's a quick fix: Try renaming your identifier so that it starts with a letter, dollar sign($) or an underscore(_). Make sure the name you choose is not a reserved keyword like "setup" or "width".

For more:
https://processing.org/examples/variables.html
https://processing.org/examples/functions.html

Incorporating Additional Resources Approach

  • When directing the users to external resources the goal is to direct them towards Processing resources when possible and towards official Java documentation as a last resort as it is significantly less user friendly than Processing resources.
  • To not overwhelm the user with links to external resources we will link them inline with the error message if the keyword is conveniently in the message itself otherwise they will be in the "For more:" section at the bottom. The "For more:" section will also contain examples of the concepts when applicable.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với java/src/processing/mode/java/preproc/PreprocessIssueMessageSimplifier.java và xem xét các chiến lược hiện có dựa trên khảo sát, các danh sách ưu tiên và mẫu thông báo lỗi được đề xuất. Issue này bao quát nhiều loại ngoại lệ và một số quyết định về thiết kế thông báo; để hoàn thành sẽ cần thống nhất phạm vi và triển khai các cách viết lại thân thiện đã chọn, bao gồm các tài nguyên liên quan và hướng dẫn theo ngữ cảnh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
developer-experience
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.