Add docs/DEBUGGING.md from Claro v1.17.26 zip
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
# Debugging Claro Programs
|
||||
|
||||
## 1) Runtime errors (OOPS screen)
|
||||
|
||||
When Claro hits a runtime error, it prints a message like:
|
||||
|
||||
```
|
||||
*** OOPS! ***
|
||||
main.claro:12: Division by zero
|
||||
Stack trace:
|
||||
at updateScore (game.claro:44)
|
||||
at main (main.claro:12)
|
||||
```
|
||||
|
||||
### What it means
|
||||
- `file:line:` is where the error happened.
|
||||
- The stack trace lists the most recent function calls.
|
||||
|
||||
## 2) TRY / CATCH
|
||||
|
||||
Errors inside TRY jump to CATCH:
|
||||
|
||||
```claro
|
||||
TRY
|
||||
CALL mightFail WITH 1
|
||||
CATCH
|
||||
SAY LASTERROR
|
||||
SAY LASTERRORFILE
|
||||
SAY LASTERRORLINE
|
||||
ENDTRY
|
||||
```
|
||||
|
||||
## 3) Static checks
|
||||
|
||||
Use:
|
||||
```bash
|
||||
claro check yourfile.claro
|
||||
```
|
||||
|
||||
This catches:
|
||||
- missing ENDIF/DONE/LEARNED/etc.
|
||||
- unknown keywords
|
||||
- CALL unknown function / wrong arg counts (semantic checks)
|
||||
|
||||
## 4) Formatting
|
||||
|
||||
Use:
|
||||
```bash
|
||||
claro fmt yourfile.claro --inplace
|
||||
```
|
||||
|
||||
This normalizes indentation and whitespace.
|
||||
Reference in New Issue
Block a user