Documentation topicsError Handling
Lexical Structure
Control Flow
Functions & Scope
Lists & Built-ins
Reference
MarathiCode v0.2.0
Error Handling
त्रुटी संदेश
Errors are reported in Marathi with the line number and the source line. For lexical and syntax errors a^ marks the position. The program stops at the first error.
| Kind | When |
|---|---|
| शब्दरचना त्रुटी (Lexical Error) | A character that is not part of the language |
| वाक्यरचना त्रुटी (Syntax Error) | Tokens in an order the grammar does not allow; reported before anything runs |
| धावपळ त्रुटी (Runtime Error) | A problem found while the program runs |
Lexical error
lexical.mr
चल x = 5 @ 2Output / Error (आउटपुट / त्रुटी)
शब्दरचना त्रुटी (Lexical Error)
ओळ 1:
चल x = 5 @ 2
^
अवैध चिन्ह '@'Syntax error
syntax.mr
चल x = 10
जर x > तर {
छापा(x)
}Output / Error (आउटपुट / त्रुटी)
वाक्यरचना त्रुटी (Syntax Error)
ओळ 2:
जर x > तर {
^
अपेक्षित अभिव्यक्ती किंवा अयोग्य विधान: 'तर'Runtime errors
| Cause | Message |
|---|---|
| Variable not defined | चल 'x' परिभाषित नाही. |
| Function not defined | कार्य 'f' सापडले नाही. |
| Wrong number of arguments | कार्य 'f' साठी 2 आर्ग्युमेंट्स आवश्यक आहेत, परंतु 1 दिले. |
| Index out of range | यादीची निर्देशांक मर्यादा ओलांडली (Index 5, length 2). |
| Operator used on the wrong kinds of values | '+' या क्रियेसाठी संख्या (number) आणि यादी (list) हे प्रकार अयोग्य आहेत. |
| Division by zero | शून्याने भागाकार करता येत नाही (Division by zero). |
| परत outside a function | 'परत' फक्त कार्याच्या आत वापरता येते. |
| थांब / पुढे outside a loop | 'थांब' / 'पुढे' फक्त लूपच्या आत वापरता येतात. |
| More than 1,000 nested calls | कार्य खूप खोलवर स्वतःला बोलावत आहे (Maximum recursion depth exceeded). |
| New function named after a built-in | 'लांबी' हे अंगभूत कार्य आहे; या नावाने नवीन कार्य बनवता येत नाही. |
| संख्या given text that is not a number | "बारा" चे संख्येत रूपांतर करता येत नाही (Not a number). |
| A result too large to store | संख्या खूप मोठी आहे (Number too large). |
type_error.mr
चल गुण = [80, 90]
छापा("एकूण: " + गुण[0])
छापा(गुण + 5)Output / Error (आउटपुट / त्रुटी)
एकूण: 80
धावपळ त्रुटी (Runtime Error)
ओळ 3:
छापा(गुण + 5)
'+' या क्रियेसाठी यादी (list) आणि संख्या (number) हे प्रकार अयोग्य आहेत.Output printed before a runtime error is kept. In the command line the error goes to standard error and the exit status is 1.