Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save obxpete/0cb4cda4c3edcaf45dc5bf4438d54da5 to your computer and use it in GitHub Desktop.
Save obxpete/0cb4cda4c3edcaf45dc5bf4438d54da5 to your computer and use it in GitHub Desktop.
Creates a service-level function
<snippet>
<content><![CDATA[/**
* @name: ${TM_FILENAME/(.+)\..+|.*/$1/:name}.${1:functionName}
* @hint: ${2:Description}
* @returns: ${3:Any}
* @date: ${4:Date}
* @author: $TM_FULLNAME ($TM_EMAIL)
*/
${5:public} ${3:Any} function ${1:functionName}(
${7}
){
var errorStruct={
arguments:arguments,
logType:"warning",
start:Now(),
stackTrace:getStackTrace(),
result:${6:{}}
};
try{
errorStruct.logType="information";
} catch( Any e ){
errorStruct.logType="error";
errorStruct.cfcatch=e;
}
errorStruct.end=Now();
errorStruct.diff=DateDiff('s',errorStruct.start,errorStruct.end);
if( errorStruct.logType!='information' || this.getdebugMode() ){
createLog(
logName=this.getdefaultLog(),
logType=errorStruct.logType,
functName=this.getcaller()&".${1:functionName}()",
args=errorStruct
);
}
return errorStruct.result;
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>svc</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment