ScriptX logotype
  • Home
  • Pricing
  • Applications
  • News
  • Documentation
Free Trial Downloads

Maintaining investment in current code - Stage 4

Discover a better way to print
  • Consistent browser-based printing, every time
  • Centralised control of print settings
  • Increase productivity and eliminate wastage
  • Easy to install and highly customisable
  • Fast and reliable, 24/7 customer support
  • Home
  • Pricing
  • Applications
  • News
  • Documentation
Developers ›  Knowledge Bank ›  How To Guides ›  ScriptX.Services ›  Then To Now ›  Stage 4

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.
  • Knowledge Bank
  • 'How To' Guides
    • ScriptX.Add-on
      • Introduction
      • Installing ScriptX on client PCs
      • Basic printing with ScriptX
      • Advanced printing features
      • Backwards compatibility
      • How to check if ScriptX is installed
      • MeadCoScriptXJS Library
      • License deployment
      • Client-side printing samples
    • ScriptX.Services
      • Introduction
      • Getting started
      • Maintaining investment in current code
        • Stage 1: Adding UI
        • Stage 2: Printing with ScriptX.Services
        • Stage 3: Summary and review
        • Stage 4: Error reporting
        • Stage 5: Prompted printing
        • Stage 6: Preparing for advanced uses
        • Stage 7: WaitForSpoolingComplete
        • Stage 8: Recommendations for some common issues
      • MeadCoScriptXJS Library
      • Printing with the API
      • Installing ScriptX.Services
        • For Windows PC v1
        • For On Premise Devices hosted on Windows Server v1
        • For On Premise Devices hosted on Windows 10 v1
        • Configure options For On Premise Devices v1
        • Cloud
      • Orchestrator
      • Debugging
      • License deployment
        • For Windows PC
        • For On Premise Devices
      • Samples
        • Configure for Windows PC
        • Configure for On Premise
        • Configure for Cloud
    • Security Manager
      • Deploying a license or revision
  • Technical Reference
    • ScriptX.Add-on
      • factory
        • baseUrl
        • ComponentVersionString
        • IsUniqueIDAvailable
        • OnDocumentComplete
        • relativeUrl
        • ResetUniqueID
        • ScriptXVersion
        • SecurityManagerVersion
        • Shutdown
        • UniqueID
      • printing
        • AddPrinterConnection
        • BatchPrintPDF
        • BatchPrintPDFEx
        • bottomMargin
        • collate
        • copies
        • currentPrinter
        • DefaultPrinter
        • disableUI
        • duplex
        • duplex2
        • EnumJobs
        • EnumPrinters
        • footer
        • GetJobsCount
        • GetMarginMeasure
        • header
        • headerFooterFont
        • IsSpooling
        • IsTemplateSupported
        • leftMargin
        • onafterprint
        • onbeforeprint
        • onbeforeunload
        • onpagesetup
        • onuserpagesetup
        • onuserprint
        • onuserprintpreview
        • orientation
        • OwnQueue
        • pageHeight
        • PageSetup
        • pageWidth
        • paperSize
        • paperSource
        • paperSource2
        • portrait
        • Preview
        • Print
        • printBackground
        • printer
        • PrintHTML
        • PrintHTMLEx
        • PrintPDF
        • PrintSetup
        • printToFileName
        • RemovePrinterConnection
        • rightMargin
        • SetMarginMeasure
        • SetPageRange
        • SetPreviewZoom
        • SetPrintScale
        • Sleep
        • templateURL
        • topMargin
        • TotalPrintPages
        • unprintableBottom
        • unprintableLeft
        • unprintableRight
        • unprintableTop
        • WaitForSpoolingComplete
      • printerControl
        • attributes
        • Bins
        • Forms
        • isLocal
        • isNetwork
        • isShared
        • Jobs
        • location
        • name
        • Pause
        • port
        • Purge
        • Resume
        • serverName
        • shareName
        • status
      • Job
        • Delete
        • Pause
        • Restart
        • Resume
      • enhancedFormatting
        • allFooterHeight
        • allHeaderHeight
        • allPagesFooter
        • allPagesHeader
        • extraFirstFooterHeight
        • extraFirstPageFooter
        • firstFooterHeight
        • firstHeaderHeight
        • firstPageFooter
        • firstPageHeader
        • pageRange
        • printingPass
      • rawPrinting
        • printer
        • printDocument
        • printString
    • ScriptX.Services
      • Web service API
        • Service Description
          • (GET)
        • Licensing
          • licensing (GET)
          • licensing (POST)
          • licensing/ping (GET)
        • PrintHtml
          • settings (GET)
          • deviceinfo (GET)
          • htmlPrintDefaults (GET)
          • print (POST)
          • status (GET)
          • download (GET)
          • canceljob (PUT)
        • PrintPdf
          • print (POST)
          • status (GET)
          • download (GET)
        • PrintDirect
          • print (POST)
      • Orchestrator API
    • Security Manager
      • How it works
      • License Expiry
      • Testing for a valid license
      • About the license file (.mlf)
        • LICENSE
        • APPLICENSE
        • TITLE
        • DOMAINS
        • DOMAIN
        • PERMISSION
      • API
        • Apply
        • License
        • result
        • validLicense
  • Articles
    • Dialogs with ScriptX.Services
    • Accessing protected content
    • Long term servicing (LTS)
 
ScriptX logotype
Home Pricing Applications News Contact us Documentation

© 2022 Mead & Co Limited.

Privacy and cookie policy

E: feedback@meadroid.com
Follow us:
LinkedIn   GitHub
X

Warning:

This ScriptX.Add-on sample can only be viewed using Internet Explorer.