Step 57 – Error Codes

The SCORM 1.2 Runtime Environment (RTE) uses a system of error codes that are set by the API, and which can be read by the SCO using three API functions:

  • LMSGetLastError()
  • LMSGetErrorString()
  • LMSGetDiagnostic()

I’ve already implemented “stubs” for these functions in my api.php code as noted in Step 10 – Other SCORM API Fuctions. But, before I make these functions active, I need to set up the error codes and related messages in the API code.

The error codes are all detailed in the SCORM 1.2 Runtime Environment specification – section 3.3.3. So, I’m going to set up a JavaScript object (which,having been brought up on perl and PHP, I tend to think of as an ‘associative array’) in the api.php code:

var errorMessages = new Object();
errorMessages['0'] = 'No Error';
errorMessages['101'] = 'General Exception';
errorMessages['201'] = 'Invalid Argument';
errorMessages['202'] = 'Element Cannot Have Children';
errorMessages['203'] = 'Element Not an Array - Cannot Have Children';
errorMessages['301'] = 'API Not Initialized';
errorMessages['401'] = 'Data Model Element Not Implemented';
errorMessages['402'] = 'Invalid Set Value - Element is a Keyword';
errorMessages['403'] = 'Invalid Set Value - Element is Read Only';
errorMessages['404'] = 'Invalid Get Value - Element is Write Only';
errorMessages['405'] = 'Invalid Set Value - Incorrect Data Type';

Why am I using strings e.g. ‘201’ rather than numbers as indices? Because it’s one of the (many) idiosyncrasies of the SCORM standard!

Next time, setting and storing the error code.

Be Sociable, Share!
This entry was posted in Run Time Environment. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *