diff --git a/package.json b/package.json index 34e7609..d6f9690 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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", "main": "dist/scorm-again.min.js", "directories": { diff --git a/src/BaseAPI.js b/src/BaseAPI.js index 8accc45..2201014 100644 --- a/src/BaseAPI.js +++ b/src/BaseAPI.js @@ -28,6 +28,7 @@ export default class BaseAPI { logLevel: global_constants.LOG_LEVEL_ERROR, selfReportSessionTime: false, alwaysSendTotalTime: false, + strict_errors: true, responseHandler: function(xhr) { let result; if (typeof xhr !== 'undefined') { @@ -185,7 +186,21 @@ export default class BaseAPI { this.#error_codes.RETRIEVE_BEFORE_INIT, this.#error_codes.RETRIEVE_AFTER_TERM)) { 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); }