Hi Guys, 

I'm building a cfc based function for my app, and I'm working on the 
'createUser' function. This function will be for creating users!

Anyways, there's quite a bit of arguments that will play into this 
function, and many possible errors that could cause the function to return 
unsuccessful. 

I'm trying to decide the best way to approach returning the errors to the 
requestee. 

As an example, user's will select a subFolder for their URL. aka 
'company.com/mySubFolder'. 

One of the arguments passed will be 'subFolder'. While I plan to make 
another function that will specifically check the subFolder's availability, 
I want an internal check on the main createUser function that checks the 
availability as well. There are also other checks that need to be placed on 
the submitted SubFolder argument. A business rule is that the subFolder 
can't be all numeric. 

I'm torn between declaring specific errors for each possible error or a 
simple 'error' variable which gets set to '1' anytime any of the possible 
errors is created. If I do the simple, single error variable, I want to 
create a 2nd variable called 'errorMemo' that would include a message 
stating what the error was. 

Here's an example of what the 'numeric' check on the SubFolder would look 
like, and it has both methods of error declarations. 

<cfif isNumeric(local.userURL) eq 1>
<cfset userURLNumericError = 1> <!--- OR --->
<cfset error = 1>
<cfset errorMemo = "">
</cfif>

Now, if I go with the specific error ('userURLNumericError') I know that 
this variable specifies one class of error. However, I'm thinking I'd still 
have to declare a 'memo' variable as well since the other option is to make 
external apps requesting this data or using this function create that memo 
on the client side. This would take a bunch of extra code. If I include an 
'errorMemo' bit with the function the client app would only need. No 
functional processing would be done on the 'memo' variable as it would be 
plain english text meant for display. 

if  userURLNumericError eq 1
print  userURLNumericErrorMemo

My other option is to just use a single 'error' variable and if any 
possible errors surface, they all just set 'error = 1'. That way I only 
have to include a single 'error' bit in the return versus about 20 specific 
error bits. 

The downside is that there'd be no way to tell the requesting app WHICH 
argument caused the error. My only solution to that is to use a single 
'errorMemo' field and as errors are created, append a new memo to the 
errorMemo variable. 

That way if 5 errors are created, I'd still only have a single 'error = 1' 
bit, but my errorMemo would read like "SubFolder Already Registered, First 
name is blank, email address is invalid'. 

The requesting app could then simply parse the errorMemo via Comma if it 
needed to. 

Thoughts?



-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

Reply via email to