Lasso Soft Inc. > Home

[lp_protect]

Linklp_protect
AuthorBil Corry
CategoryError
Version8.x
LicensePublic Domain
Posted03 Dec 2005
Updated30 Oct 2006
More by this author...

Description

Similar to [protect] but allows errors to extend outside protect block.  Basically, you can catch certain errors (and optionally clear them), and allow all other errors to propagate outside the lp_protect block.

Note that this ctag is a container ctag, and as such must be loaded within LassoStartup.  You can not use this tag if it is loaded at the page level.

Sample Usage

// no failure
lp_protect;
	handle: (error_currenterror: -errorcode) == 1234;
		'Caught error 1234 : ';
		lp_error_clearerror;
	/handle;
	'No failure : ';
/lp_protect;
'error outside of protect block is ' + error_currenterror + '
'; // failure we want to catch lp_protect; fail: 1234, 'Clunk!'; handle: (error_currenterror: -errorcode) == 1234; 'Caught error 1234 : '; lp_error_clearerror; /handle; 'No failure : '; /lp_protect; 'error outside of protect block is ' + error_currenterror + '
'; // failure we want to propagate up lp_protect; fail: 5, 'Clunk!'; handle: (error_currenterror: -errorcode) == 1234; 'Caught error 1234 : '; lp_error_clearerror; /handle; 'No failure : '; /lp_protect; 'error outside of protect block is ' + error_currenterror + '
';

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

[

define_tag:'lp_protect',
	-description='Similar to [protect] but allows errors to extend outside protect block.',
	-container;
	
	// save error so we won't overwrite it with our protect below
	local:'_ec' = error_code;
	local:'_em' = error_msg;
	lp_error_clearError;

	local:'lp_protect_run_children' = string;
	local:'lp_protect_errormessage' = string;
	local:'lp_protect_errorcode' = string;
	protect;
		#lp_protect_run_children = run_children;
		handle;
			#lp_protect_errormessage = error_currenterror;
			#lp_protect_errorcode = (error_currenterror: -errorcode);
		/handle;
	/protect;
	if: #lp_protect_errorcode != 0;
		fail: #lp_protect_errorcode, #lp_protect_errormessage;
	/if;

	// restore the error, if any
	error_code = #_ec;
	error_msg  = #_em;

	return: #lp_protect_run_children;

/define_tag;

]

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft