Jump to content

Recommended Posts

Not strictly php, but this seems a reasonable place to ask 

 

If documenting a routine ( which may or not directly throw an exception ), but whichh calls another one which definitely DOES, how would one write the @throws lines in the procedure header?

 

1. Ignore the exceptions thrown by called routines.

2. Attempt to create and maintain a list of @throws which reflect ANYTHING the routine and its callees can throw.

3. List exceptions thrown by this routine explicitly, and add 

        @throws as fred()

    for each routine we know is called and may throw something.

 

1. Is consistent and easy to maintain, but scarcely useful.

2. Is a maintenance nightmare.

3. Is a slightly smaller nightmare.

 

I guess what is needed is an automated system that scans the routine source but I haven't been introduced to anything of that ilk.

 

David

Link to comment
https://forums.phpfreaks.com/topic/293749-documenting-thrown-exceptions/
Share on other sites

You can throw errors all day long - don't waste the time. A critical error - DB ect - log it - but there is zero recovery - tell your users - 'hello' is about it. Another less critical-error - ok, continue on with a polite message. But - error checking every thing will just drive you crazy and won't do anything in the end.

Edited by hansford

Personally, I'd go ahead and document the exception with a @throws tag because when another method calls that method, there's a chance it's going to have to catch and deal with the exception the child method throws. I guess there are arguments you could make depending on the visibility or scope of each of the methods, but I like my documentation thorough and have a bit of a tendency to overdo it some times.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.