It’s easy to make mistakes while programming! We all do it—learn to love it! When we run our code, a piece of software called a compiler tries to translate our code into machine code (code a computer understands). When the compiler gets to a piece of code that it can’t interpret, it throws an error showing where it stopped and why.
You may recognize this as the scary red text that sometimes shows up in the terminal.
Here’s an example of an Emojicode error:
example.emojic:3:0: 🚨 error: Unexpected end of program.
Let’s walk through the error together:
example.emojicrefers to the file we’re running.
3refers to the line of code that caused the problem.
0refers to the specific character within that line.
🚨 errorwell… that tells us it’s an error!
Unexpected end of programis the specific issue.
Oh… whoops. We figured out why our code wasn’t working—we left off the closing
🍉. Thanks, error!
Unfortunately, not every error message is so helpful. When we see an error in our terminal, we should first check to see if it points us directly to the broken code. If not, we should assume we made a syntax error, a typo or mistake in our code that prevents it from compiling.
Help! We made a few mistakes in our code! Fix all the problems in our code so that instead of an error, the following prints to the terminal:
Don't you think Errors are great Don't you think Errors are fun? Don't despair! Try not to hate They happen to everyone
Note: Try to pinpoint the errors one by one. It will take some trial and error so make sure to be patient.