Debugging
What the red message means, why it happens and how to find it. Every page has a broken program to fix.
How to read any error
- Read the last line first. It names the error and usually the thing it tripped on.
- Find the line number. That is where it noticed, which is often just after where it went wrong.
- Say what you expected. What did you think that value or name was at that moment?
- Check it. Print the value, or read the line out loud, before changing anything.
- Change one thing, run again. A new error is progress: you got further.
Python
AttributeErrorThe value has no method or attribute with that name.DoneIndentationErrorThe spaces at the start of a line do not fit the block.DoneIndexErrorA list or string was asked for a position it does not have.DoneKeyErrorA dictionary was asked for a key it does not have.DoneNameErrorA line uses a name Python has never been given.DoneSyntaxErrorPython could not read the code, so nothing ran.DoneTypeErrorAn operation got the wrong kind of value.DoneValueErrorThe type is right, but the value cannot be used.DoneZeroDivisionErrorSomething was divided by zero.Done
Web
Assignment to constant variableA line tried to give a const a new value.Doneis not a functionSomething that is not a function was called with brackets.DoneReferenceErrorA line uses a name that does not exist where it runs.DoneSyntaxErrorJavaScript could not read the code, so nothing ran.DoneCannot read properties of undefinedA property was read from undefined or null.Done
SQL
ambiguous column nameTwo joined tables share a column name and the query did not say which.Donemisuse of aggregateCOUNT, SUM or AVG was used where single rows are tested.Doneno such columnThe table has no column with that name.Doneno such tableThe database has no table with that name.Donesyntax errorThe query breaks SQL grammar at or just before the word it names.Done
C
divide by zeroA whole number was divided by 0 while the program ran.Done';' expectedThe compiler wanted a symbol, often missing on the line above.Donememory access out of boundsThe program touched memory past an array or through a bad pointer.DoneMaximum call stack size exceededA function kept calling itself and never stopped.DoneundeclaredA line uses a name the compiler has not seen yet.Done