Error reporting

This walk-through illustrates taking a classic document that has a controlled print experience and works only in Internet Explorer and making it work with ScriptX.Services in any browser on any platform using the minimum amount of development effort and making as few changes as possible (though more changes might be desirable).

Previously : Stage 3 - Summary and review

Some of the defects in the code that we will address are improvements that could/should have been made to the “old” code too but from here on we will work to improve working with ScriptX.Services knowing that many of these changes will benefit working with ScriptX.Add-on too.

Helping with debugging

It is useful to have some information on the processes being performed. The  ScriptX.Services Client Library generates a lot of log lines to the console but these are suppressed by default and need to be enabled.



Error reporting

Errors that occur are reported in the console and also with a simple alert box. The functions that report the errors can be overwritten to use the application error UI.

The functions to be overwritten are:

  • MeadCo.ScriptX.Print.reportServerError

    Called when an error occurs with a single string argument containing the text of the error.

  • MeadCo.ScriptX.Print.reportFeatureNotImplemented

    Called when a feature is used that is not yet implemented with a single string argument containing the descriptioon of the feature.

// If ScriptX.Services client libraries have been loaded then overload the error report functions
// to use the error reporting code for the application (for demonstration, we use simple javascript alert).
if (typeof MeadCo === "object" && typeof MeadCo.ScriptX === "object" && typeof MeadCo.ScriptX.Print === "object") {
	// overload cloud print library report error
	MeadCo.ScriptX.Print.reportServerError = function (errorTxt) {
		console.error(errorTxt);
		alert("ScriptX.Services error\n\n" + errorTxt);
	}

	MeadCo.ScriptX.Print.reportFeatureNotImplemented = function (featureDescription) {
		var msg = "Sorry " + featureDescription +
			" is not available yet with ScriptX.Services."
			
		console.warn(msg);
		alert(msg);
	}
}

Open your browser (any browser) and go to the address  https://scriptxprintsamples.meadroid.com/ThenToNow/now-stage4

Touch “Preview” and note that the error message is as coded above.

Next up: Stage 5 - Prompted printing.