Catching getValue errors, same as setValue
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "scorm-again",
|
"name": "scorm-again",
|
||||||
"version": "1.5.3",
|
"version": "1.6.0",
|
||||||
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
|
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
|
||||||
"main": "dist/scorm-again.min.js",
|
"main": "dist/scorm-again.min.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export default class BaseAPI {
|
|||||||
logLevel: global_constants.LOG_LEVEL_ERROR,
|
logLevel: global_constants.LOG_LEVEL_ERROR,
|
||||||
selfReportSessionTime: false,
|
selfReportSessionTime: false,
|
||||||
alwaysSendTotalTime: false,
|
alwaysSendTotalTime: false,
|
||||||
|
strict_errors: true,
|
||||||
responseHandler: function(xhr) {
|
responseHandler: function(xhr) {
|
||||||
let result;
|
let result;
|
||||||
if (typeof xhr !== 'undefined') {
|
if (typeof xhr !== 'undefined') {
|
||||||
@@ -185,7 +186,21 @@ export default class BaseAPI {
|
|||||||
this.#error_codes.RETRIEVE_BEFORE_INIT,
|
this.#error_codes.RETRIEVE_BEFORE_INIT,
|
||||||
this.#error_codes.RETRIEVE_AFTER_TERM)) {
|
this.#error_codes.RETRIEVE_AFTER_TERM)) {
|
||||||
if (checkTerminated) this.lastErrorCode = 0;
|
if (checkTerminated) this.lastErrorCode = 0;
|
||||||
returnValue = this.getCMIValue(CMIElement);
|
try {
|
||||||
|
returnValue = this.getCMIValue(CMIElement);
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ValidationError) {
|
||||||
|
this.lastErrorCode = e.errorCode;
|
||||||
|
returnValue = global_constants.SCORM_FALSE;
|
||||||
|
} else {
|
||||||
|
if (e.message) {
|
||||||
|
console.error(e.message);
|
||||||
|
} else {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
this.throwSCORMError(this.#error_codes.GENERAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.processListeners(callbackName, CMIElement);
|
this.processListeners(callbackName, CMIElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user