SDKs
...
Tutorials
Best Practices
Error Handling
7min
error handling is an integral part of software development this article provides effective ways to handle licensespring errors and keep your application secure prerequisites completed the getting started docid\ lsfy9tq3vfq4roow9shkd tutorial, specifically initialized licensemanager (or licensehandler ) with your configuration using the appropriate settings created a licenseid using either licenseid fromkey or licenseid fromuser function, depending on the activation method you prefer implemented basic license management, including license activations, deactivations, and both online and local license checks handling exceptions methods of license and licensemanager classes throw exceptions if something went wrong put the methods that can produce exceptions in try catch block licensespringexception is the base class of all sdk exceptions the good practice is to implement separate logic for different types of exceptions below is the example of handling device id mismatch instead of closing the application, we can try to upgrade to a new device id algorithm see hardware id docid\ yfnucnixyzano8e sy5i1 try { license >localcheck(); } catch( const devicenotlicensedexception& ex ) { // handling specific error trying to upgrade to new device id algorithm license = m licensemanager >relinklicense( wincryptographyid ); return; } catch( const licensespringexception& ex ) { std cout << "licensespring exception encountered " << ex what(); }try { license localcheck(); } catch( devicenotlicensedexception ex ) { // handling specific error trying to upgrade to new device id algorithm license = manager relinklicense( deviceidalgorithm gen3 ); return; } catch (licensespringexception ex ) { console writeline( "licensespring exception encountered {0}", ex message ); } common exceptions below is the list of the exceptions that can occur on any sdk request exception definition licensestateexception license is disabled, was reset or expired signaturemismatchexception in case signature returned by licensespring server is not valid e g if the response data was changed nointernetexception networktimeoutexception licenseserverexception connection related errors if there's no internet or an internal server error occured see license checks docid\ ie dah13b4dqxmaqoygrj apikeyexception if provided api key cannot be used for the request( is invalid, readonly or revoked) authorizationexception authorization failed, please check your proxy settings handling c++ errors the licensehandler class of c++ sdk is exception free by default it provides an alternative way to implement licensing without exceptions but c style error codes make sure to put error checks after licensehandler calls to retrieve the error use the following methods bool licensehandler waserror() const; //check if there was an error lserrorcode licensehandler getlasterror() const; //get code of the last error const std string& licensehandler getlasterrormsg() const;//get message of the last error this class also contains several methods to check for error type, e g islicensestateerror , isnointerneterror example of handling licensehandler errors licensehandler checklicenselocal(); if( licensehandler waserror() ) { if( licensehandler getlasterror() == edeviceerror ) licensehandler relinklicense( wincryptographyid ); else std cout << "licensespring error encountered " << licensehandler getlasterrormsg(); } common errors below is the list of the exceptions that can occur on any sdk request error definition estderror c++ standard exception encountered esignaturemismatcherror server signature is not valid e g if the response data was changed enointerneterror enetworktimeouterror eservererror connection related errors if there's no internet or an internal server error occured see license checks docid\ ie dah13b4dqxmaqoygrj einvalidapikey ereadonlyapikey erevokedapikey eapikeyproductnotallowed if provided api key cannot be used for the request( is invalid, readonly or revoked) eauthorizationerror authorization failed, please check your proxy settings handling swift errors swift sdk uses lserror compatible with nserror for error reporting any sdk method marked as throws produces lserror in case of error possible error codes described as enum lserrorcode swift do { try license fullcheck() } catch let error as lserror { print("licensespring error \\(error)") } catch { print("unknown error \\(error)") }