Smalltalk tutorial Error & Exception Messages. Using the Debugger.

Error & Exception Messages



More Tutorials
C Programming Tutorial
T223

HTML Tutorial & Web Design
T170,T171 and TT180

Search this site

Home

 

Tutorials
| 1. Starting Smalltalk, and Terminology | 2. Precedence Rules | 3. Classes - Strings | 4. Class Browser | 5. Variables | 6. Error Messages | 12. Control Structures | 16. Dialogs | 23. Collection class | 39. OpenGUI |

 

Information
| Smalltalk Books | Student Software & Books | Hints & Tips | Sites | Download Smalltalk | Coloured code | Download Documents | ASCII Codes |

 

Smalltalk Index

 

 

 

 

Contents

Error messages  
List of error messages

Argument expected
Attempt to store into Argument
My subclass should have overridden one of my messages
Nothing more expected
Right parentheses is expected
Unhandled exception: Message not understood #XXX
Unhandled exception: xxxx
xxxx is a GUI property name
Will not be optimised
NonBoolean receiver--proceed for truth

How to Use the Debugger LearningBook will not open
Other useful things you can use the Debugger Book for...  

Error messages

Error messages and Exception messages are covered in Chapter 17 of the Course book, but you can expect Error messages and Exception messages as soon as you start using LearningWorks.


The following are some of the errors that Smalltalk may come across when it tries to translate an expression into machine-readable form.
  • Syntax errors, such as incorrect use of punctuation.
  • Unrecognised names -- even though the form of the message expression is correct, you have used a name that the translator does not recognise, may be due to misspelling.

Top


List of some of the error messages

Copy this table to a word processor as a starter kit for your own list of errors.
Do this early in the OU course to obtain maximum benifit, and to save you, not hours, but days of time. Errors will drive you crazy.

Error or Exception Message

Possible Cause(s)

Comments

Argument expected->

You have omitted an argument in a keyword message.

missing [ ]

An earlier method expects an argument. E.g. Evaluating 2 + in the Workspace would produce this error

The method you used expected a block. i.e. [ ]

Attempt to store into Argument You cannot assign into a variable which is an argument of the method A NoNo Example.
debit : anAmount
"Comment- anAmount is an argument of keyword method debit"
anAmount :=3

A flashing GC cursor .





Endless loopcaused by a method that references itself from within the method. .
E.g. If you have a method called, method1. Do NOT use code similar to, self method1, within the method, which will cause an endless loop, and if you are not careful a computer crash.
Often the use of super instead of self cures this problem

Check that whileTrue: methods will iterate towards a false answer

Check that whileFalse: methods will iterate towards a true answer

REMEMBER Ctrl + q if this happens.

Then ensure that the method is NOT referenced from within the method.

The flashing GC cursor is a fairly common error, until you know how to avoid it. TMAs are written in such a way that the student is likely to fall into the "GC" trap.

To break out of loop. Hold down Ctrl then press q (or possibly Ctrl + Q)
Other ways of rectifying can result in Loss of your work.
Often occurs when self is used rather than super

The GC Indicates that Garbage Collection is in operation.

Be aware of this from TMA 2 onwards

is not supported by your model   Answer to problem

‘ My subclass should have overridden one of my messages ’

Using super instead of self

Chap 21 page 10. Chap 45 page 20

NonBoolean receiver--proceed for truth The receiver should be true (or false). Or an expression that that relsults in true or false. must be true NOT True

 

Nothing more expected->

 

Missing . (Full stop) or a full stop where there should not be one

Look immediately before the error message.

Missing ( Left parentheses

Look before the error message.

Right parentheses is expected

Missing ) Right parentheses

Look before the error message. The error is often only detected when a full stop is reached

someVars's value is never used   A tempary variable has been declared but not used. A common errer in the development stage of writing a method.

Unhandled exception: xxxx

xxxx is a GUI property name

Missing end "

Misspelling of name.

Look after the error message.

See Using GUI (Chap 39) Simplified steps

Unhandled exception: Message not understood #XXX

 

The receiver is not a suitable object to receive that message.

E.g.
'two' + 1

Where XXX is the message and is not in the protocol of the receiver.
The message XXX is being sent to the WRONG object

two' is a string object, which does NOT have the binary message + 1 in its protocol. The number object 2 understands the message + 1.

Unhandled exception: My subclass should have overridden one of my messages   A message in in the superclass should have been overridden in the subclass. The method has not been written and an unacceptable superclass method is been used.
Will not be optimised

Missing [ ]

E.g. using ifTrue: frog1 leftrather than ifTrue: [ frog1 left ]

Some messages give you the option to press the proceed button. I recommend that you DON'T, use the debug or cancel buttons, find and rectify the error.

Top


How to Use the Debugger



{M206 Smalltalk unhandled exception notifier window}
Figure 1. System Error notifier window

 

{M206 Smalltalk debugger, Error tab}
Figure 2. Debugger Book-Error tab

 

{M206 Smalltalk debugger, Messages tab}
Figure 3. Debugger Book-Messages tab
Finding the Cause of an error.
  1. If you receive the System Error Unhandled exception notifier window. Figure 1. This one was carried out by executing LB 17 Practical 15.
  2. Your expression or code has created an error.
  3. The wording that follows, in this case Message not understood: is stating the problem. Note that this error is in the list above.
  4. # Discount this bit
  5. position: is the message that was not understood.
  6. Click the debug button.
  7. In the Debugger Book. Figure 2. Click the Messages tab
  8. See Figure 3.
  9. Enlarge the Debugger Book to see all or most of the code etc. in the bottom pane
  10. look through the messages in the top pane. Click them in turn and look at the code in the bottom pane
  11. Usually you are looking for code that YOU have written, i.e. the source of the problem. Usually the source in in the messages at the bottom of the list
  12. Make a note of the code, the portion of the code that is highlighted, and where it is found:- Workspace or Name of Method.
  13. The example in Figure 4 is an expression in the Workspace, the Text Editor Evaluation points to this
  14. Close the Debugger Book and then you can correct your error.

LearningBook will not open

Note if a LearningBook will not open the source of the problem is usually in a Class initialize method

  • Use the above steps to find the Class initialize method.
  • When you find it, place double quotes before and after all your code in that method.
  • Click the Accept button.
  • Click restart.

Top


Other useful things you can use the Debugger Book for...

  • Stepping through your method(s). Useful if your method(s) do not produce the expected result.
  • Checking the state, arguments and variables.

 

 

Top of Page.

 

Sites by John McGuinn . HTML and Web Design | C Programming

Leeds & the UK Tourist Information & guide my home town

Relax in the sun.

Benidorm   Tenerife   San Marino apartments to rent

Holidays and Short Breaks     Manchester Airport

Leeds my home town City of Leeds information  Leeds and Bradford International Airport

AireWeb Web Design
Leeds Web Design Web Designers Hosting Domain names Web site Promotion

Copyright © John McGuinn 2000 - 04