Reading errors
What the language tells you when something is wrong
Making mistakes is part of learning. The good news is that Ahadu says clearly what went wrong.
Every error carries three things: a code, a message, and a place.
[AH3001] "ያልተሰየመ" የሚባል ተለዋጭ አልተገለጸም።: መስመር 1 ላይ: 4ኛው ካራክተር
AH3001 is the code. The message states the problem. The line and column say
where to look.
Three kinds of error
The number the code starts with tells you when the problem was found.
AH1 — lexical
Found while splitting the text into words. A character that means nothing:
[AH1001] የማይታወቅ ካራክተር አለ።: መስመር 1 ላይ: 7ኛው ካራክተር
Or indentation that does not line up:
[AH1002] የመስመር መጀመሪያ ክፍተት ስተት፡: መስመር 2 ላይ: 1ኛው ካራክተር
AH2 — syntax
The words are fine but their arrangement is not:
[AH2002] የመዝጊያ ቅንፍ ")" ረስተዋል። የመክፈቻው በመስመር 1 ላይ ነው።: መስመር 1 ላይ: 11ኛው ካራክተር
Both of these are found before the program starts, so you are told without a single line having run.
AH3 — runtime
Raised while the program runs. Everything before it really did happen.
[AH3003] በዘሮ ማካፈል አይቻልም።: መስመር 2 ላይ: 4ኛው ካራክተር
Dividing by zero cannot be spotted while reading the program — whether the divisor is zero is only known once it runs. That is exactly why it is an AH3.
This grouping is a promise about when a problem can be detected, not a filing system. It is why
AH3003could never be anAH2.
Errors you will meet
| Code | Meaning |
|---|---|
AH3001 |
a variable was used before it was given a value |
AH3003 |
division by zero |
AH3008 |
a position outside the collection was asked for |
AH1002 |
the indentation at the start of a line is wrong |
AH2002 |
a bracket was never closed |
The full list is in the reference.
How to fix one
- Read the code — AH1 or AH3 tells you where to look
- Go to the line — start where the error points
- Change one thing — then run it again
Try fixing the examples above. For the first one, give ያልተሰየመ a value
before using it.
Exercise
This program has three mistakes. Find them and fix them.
[AH1002] የመስመር መጀመሪያ ክፍተት ስተት፡: መስመር 4 ላይ: 1ኛው ካራክተር
Show the answer
The mistakes are: an indent that should not be there, a missing ፦, and a
counter that never grows.
6