How to read Error Messages

In the event that something goes wrong when your code is uploaded and run, you will receive and error message based on the type of error as well as a more detailed message for certain errors. Here you will find a brief description of the error messages and how to read them.

Types of Python Errors

Python Syntax Error:

If your Python code contains a syntax error, you will receive a python syntax error error. Syntax errors are usually caused by a typo, misspelling a variable or reserved word, or improperly formatting your indentation. Basically, the Python interpreter is having difficulty parsing (reading and translating) your code. The message will include which line or lines of code caused the error and what type of error.

Take the example below:

Python Syntax Error:

Your code encountered a syntax error while running, See Below

File "\upload\Smith_John.py",

line 10

myCol = random.randint(0,2)

^

SyntaxError: mismatched input '' expecting DEDENT

In this case, you can see there is an error on line 10 of the file that we uploaded Smith_John.py. In this case, it specifies that there was a dedent expected where there wasn't one. this is caused by an extra tab that was left in the code:

myCol = random.randint(0,2)

Should be on the same tab level as the lines before it like this:

myCol = random.randint(0,2)

Because Python uses tabs and indentation to delimit blocks of code (as opposed to some other languages like Java and C++ which use curly braces), it is essential you keep track of and properly indent your code

You can also see the difference between syntax errors and exceptions HERE

Security Error:

Our security policy prevents file IO, networking, and certain other functionality that may pose a risk to security. Check the error message and your code to see where the issue is.

PLEASE NOTE: Submitted code is run using an implementation of Jython, which allows python code to be executed in the Java Virtual Machine (JVM). Security errors are handled by the JVM, so you may see java mentioned in the security error message. Also please note that aside from the sandboxing that the JVM provides, our entire app is run in a containerized environment that creates a new instance of the container each time the site is accessed.

Timeout Error:

This occurs when the game in which your computer player is playing takes longer than 20 seconds to complete. This can occur if there is some sort of infinite loop or your code is waiting for input. Please note: your code should not wait for console input, but it shouln’t need to anyway. In the event there is an infinite loop in your code, check to be sure that every lopp in your code is properly terminated and does not continue forever.

Out Of Memory Error:

This will occur if too much memory is being consumed by the virtual environment in which your player is running. In this case, make sure that there are no loops that are creating objects infinitely, any extensive recursion or any other types of memory leaks

Python Exception Error:

This error occurs if any other type of exception occurs when trying to run your player. These exceptions (or errors) occur at runtime (or when your code is actually running) There a quite a few different types of exceptions in python, so it would be difficult to list them all here. You can find a list of the most common and what causes them HERE

Here’s an example of an IndexError which occurs when you attempt to access an index of an list that is outside of the bounds of the list’s size:

Python Exception Error:

Your code encountered an error while running, please see below...

Traceback (most recent call last):

File "\upload\Smith_John.py", line 10, in calcMove

print(list[4])

IndexError: index out of range: 4

You can see which line the exception was on (In this case line 10) and the offending line itself:

print(list[4])

Which attempts to access the value of the list "list' at index "4" which is out of bounds. At the bottom you can see the specific error and what caused it:

IndexError: index out of range: 4

It is important to read the message carefully. Somtimes it might not be perfectly clear what is causing the error. Keep calm, double check the lines referenced by the error, and refer to the link above on Python exceptions to see what causes them.

Types of Java Errors

Compile Error:

First, it’s important to remember that java source code must first be compiled before it can be run. This is the process of “translating” the code into machine code that a computer can run. The java compiler will detect problems in the syntax of your code and tell you if it fails to compile. There are various errors that can occur during compilation, but this can be useful in figuring out problems before the code is run.

If your java code fails to compile, you will receive a compile error. The message will include which line or lines of code caused the error and what type of error.

Take the example below:

Compile Error:

Your class did not compile. Refer to the error below

/upload/Smith_John.java:11: error: illegal start of expression

char mySymbol = getTeam(; // my symbol

^

/upload/Smith_John.java:11: error: ';' expected

char mySymbol = getTeam(; // my symbol

^

/upload/Smith_John.java:12: error: not a statement

char oppSymbol; // opponent's symbol

^

3 errors

In this case, you can see there are 3 errors that occur on lines 11 and 12 (In the source code file Smith_John.java). Sometimes, the compiler can’t give you an exact answer to what caused the problem, it can only tell you the problems it encountered. In this case the 3 errors were caused by one typo on line 11:

char mySymbol = getTeam(;

Should have a closing parenthesis on the function call like this:

char mySymbol = getTeam();

Because the closing parenthesis was missing, it caused the compiler to have problems parsing (translating) the surrounding code, which is why we have multiple errors. Usually, you can tell which line is causing the problem or problems, but you might need to use a bit of reasoning to figure out exactly what the issue is.

You can also see a list of compile error messages and what they usually mean HERE

Class Creation Error:

These types of errors occur when your class is not formatted properly and our app has difficulty loading or instantiating your class.

This is most likely due to the fact that your code does not follow the proper formatting.

Remember your class MUST:

Inherit from or “extend” the class Player (make sure the “P” is uppercase)

Contain the public void method calcMove()

You must not create your own constructor (you shouldn’t need one)

Sometimes your code will not even compile and you will get a compile error when these conditions are not met, so be sure to read the error carefully.

Security Error:

This error will occur if you attempt to use a method from a package that is not allowed by our security policy.

Normally, when you compile and run a piece of code on your machine, you trust it because you wrote it and it runs with full “security clearance” However, since we are allowing you to upload your own code, we have to be sure that it can’t do anything… nefarious. So we have limited the packages that you can import and use from the java library and also prevent you from using some other functionality.

The packages you can use are:

java.lang

java.util

java.io (but you cannot use file io or network io)

java.math

java.time

You are also prevented from creating classloaders, using the java.lang.reflet package, or calling System.exit() as well as other things.

You can see which line of your code is causing the error by looking at the stack trace (which is the long error message at the bottom) and looking for your class name and the line number, something like Smith_Jon.calcMove():17 (in this case the error occurred in line 17 of the calcMove function.

PLEASE NOTE: Submitted code is run in a sandboxed environment to prevent other security issues.

Timeout Error:

This occurs when the game in which your computer player is playing takes longer than 20 seconds to complete. This can occur if there is some sort of infinite loop or your code is waiting for input. Please note: your code should not wait for console input, but it shouln’t need to anyway. In the event there is an infinite loop in your code, check to be sure that every lopp in your code is properly terminated and does not continue forever.

Out Of Memory Error:

This will occur if too much memory is being consumed by the virtual environment in which your player is running. In this case, make sure that there are no loops that are creating objects infinitely, any extensive recursion or any other types of memory leaks

Exception Error:

This error occurs if any other type of exception occurs when trying to run your player. These exceptions (or errors) occur at runtime (or when your code is actually running) There a quite a few different types of exceptions in java, so it would be difficult to list them all here. You can find a list of the most common and what causes them HERE

Here’s an example of an ArrayOutOfBoundsException which occurs when you attempt to access an index of an array that is outside of the bounds of the array’s size:

Exception Error:

An Unspecified error occured when running your player. See Below

java.lang.ArrayIndexOutOfBoundsException: 12

at Smith_John.calcMove(Smith_John.java:170)

at Game.playMove(Game.java:250)

at Game.playGame(Game.java:63)

at SandboxProcess.main(SandboxProcess.java:104)

You can see the type of error from the first line and what value caused the exception (in this case the value 12 was used as an index of an array that did not contain and index of 12):

java.lang.ArrayIndexOutOfBoundsException: 12

And you can see that it occured in line 170 of class Smith_John (or your submitted class)

at Smith_John.calcMove(Smith_John.java:170)

You don’t need to worry about the other lines, they specify the stack trace, or the pathway of method calls that led to the error (It called playGame() and playMove() from the class Game, which called your calcMove() method)