Forum Moderators: coopster

Message Too Old, No Replies

Where should I do my error checking?

         

bobnew32

6:50 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



Ok, I have this sample code:

class PrivateMessageFolder {

function deleteFolder($_spillOverFolderId) {

}

}

Now, in the delete folder function, it obviously deletes the folder, and moves all the private messages to the spill over folder.

My question is, where do I do my error checking to make sure that, lets say the spill over folder is owned by the owner of the folder being deleted? Do I do it before I call

$object->deleteFolder($_spillOverFolderId)

or do I do it inside the function? I am just unsure where to do error checking for classes, while keeping them reusable.

fmaz

6:54 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



Well, you do the error checking BEFORE the line of code that delete your folder ..

if their is an error, you just do this:

die("Sorry, their is an error, the folder will not be deleted");

or, better (if it's inside a function)

echo "Error ... bla bla bla";
return;

bobnew32

6:56 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



I'm just saying, instead of checking inside the class itself to see if the owner of the folder being deleted is the owner of the spill over folder, I do that outside of the class and when I call:

deleteFolder($_spillOverFolderId);

It simply moves the messages and deletes them; no checking for user ownership of the folders in question.

fmaz

7:18 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



so, where is the problem, you do your validation, then, if all is OK, you call your function ...

? no?