A Wee Tiny Blog uses a number of constants to indicate if something has gone wrong, and if so, what exactly the problem was. These codes are all defined as constant strings, so you can not only use them in comparisons, you can also directly write them to a log or echo them to the user.
To retrieve the last error code, call
GetLastError. Alternatively, to clear an error code, call
ClearError. Clearing error codes is optional, and it's usually only used when you've already recovered from an error.
Below is a list of each error code and an explination for why you've encountered it.
AWEETINYBLOG_ERROR_DB_CONNECT_FAILED
If the
ConnectToDatabase method can connect to MySQL but can't access the given database, this error is returned. Check that you've spelled the database's name correctly and that the MySQL user your script uses has permissions for this specific database.
AWEETINYBLOG_ERROR_FREE
This is the ideal and default value of the error flag -- it means that your script has been free of errors so far.
AWEETINYBLOG_ERROR_INVALID_PARAM
Most of the methods in the AWeeTinyBlog class will set this error code and abort if one or more of their parameters are invalid. Examples range from the method expecting a number and getting some text to the method receiving the wrong number of parameters.
AWEETINYBLOG_ERROR_MYSQL_CONNECT_FAILED
The
ConnectToDatabase method can return this error if it was unable to access MySQL. This might be due to an invalid username or password, or your MySQL setup isn't properly configured.
AWEETINYBLOG_ERROR_NOT_CONNECTED
A Wee Tiny Blog requires access to a MySQL database to work. If you try to use any method without first connecting the object to a database, this error code is set and the method aborts.
AWEETINYBLOG_ERROR_NOT_FOUND
This error code is less severe than the others. It simply means that whatever entry or entries you tried to access don't exist.
AWEETINYBLOG_ERROR_QUERY_FAILED
This indicates a MySQL error -- a query didn't run properly for whatever reason. To debug this further, try using
GetMySQLError to see what MySQL has to say about the problem.
AWEETINYBLOG_ERROR_UNKNOWN_DATE
This error is exclusive to the
NavigationAids method. It appears when you've attempted to call
NavigationAids before any method that returns entries. The reason for this is that navigation links can't be generated without knowing where to start.