Errors handler in Text Express
Introduction
In order to achieve the design of the authentication flow, a lot of functions have to be called one after another to the backend. So many consecutive calls to the backend could also bring a lot of errors, due to low and unstable internet connection. If those errors happen, the game should handle them separately and show a specific GUI to the player. I noticed that most errors in the game have similar text and images, however, most of them are being called from different classes in the game.

Design
To make it easier for me to track all errors regarding the authentication flow, I created a document which shows how the game handles every error and what is expected from the player in order to retry. Also, as every error should have its own dedicated error GUI, the document I created, also helped in the creation of those GUIs and as well deciding what the text presented to the player should be:
Realization
With the view not to call everything from different classes in the game, I decided to create an error controller class, which will follow the SOLID- Single responsibility principle, with the idea that all generated errors within the game, will be generated in one class, so that they can be easily extended, modified and maintained.
When generating an error, the developer should specify the type of the error, as well as the error code.

Type of the error- Depending on the type of the error, a different GUI is shown to the player (Could be: authentication, backend, client, etc.).
Error code- It is good practice that the developers give the player information they can work with and don't bother the player with technical explanations, but rather tell him roughly what went wrong and what can be done about it. However, for the developers it is really good to know at what specific place the code breaks and what the reason for that break could be. That's why I decided that all errors should have their own unique code, which is shown under all GUIs. If a player then reports an error, he can provide the error code to customer support, and then the error will be easily found. As a product for this error provider system I've created the following "error sheet", which gives more information to the developers and QA testers about the error codes:
Extra Problems faced:
All the text in Text Express is stored on a google sheet. This is done, so that we can, later on, localize the text and for example show Dutch text when the game is played in the Netherlands and German in Germany and Austria:

However, I noticed a bug, when I want to write a new line in the text. When I write the command "\n" in the google sheet text I would expect to have a new line in the displaying in-game text. However, I was getting the following in-game text:

When reading about why is this happening and how to tackle it I discovered the following: C# works in a way that when it reads text from an external source (google sheet, word document, etc.), it treats the "\n" command, as if it is part of the plain text and automatically makes it to "\\n", which later on results in a "\n" in the text and not a new line.
Therefore, I found that using "<br>" will always result in a new line, no matter where the text is coming from.
Evaluation
Now having this system, it is easier for QA to track errors and then for developers to fix them, as they immediately know where the code failed.
For the future
If all errors in Text Express are called this way, the tracking of bugs will be way faster and easier. In order for that to happen, quite some time should be spent to refactor the code and rewrite it to show an error using this class, however, I believe that is worth it.
Last updated