Tagged Questions

Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution.

learn more… | top users | synonyms

2
votes
2answers
157 views

Encapsulating common Try-Catch code. Is this a known pattern? Is it good or bad?

In an effort to reduce code duplication, I often use and have used this style to capture handling of exceptions on a boundary of an application: Given the following extension methods: public static ...
1
vote
3answers
98 views

I think I'm not using Try Except properly in this Python code

Please offer some advice for this code. It all works, but I know that its messy and I don't think the Exception catching is doing what I want it to. Thanks in advance for any and all advice... def ...
1
vote
1answer
31 views

LPTHW - ex48 - Handling exceptions and unit testing

This is my solution to the exercise 48 of Learn Python the hard way by Zed Shaw. Please visit the link for testing suite and requirements. I'm worried about my the word banks I have created (COMPASS, ...
2
votes
2answers
107 views

HttpClient error handling

I would be happy to hear feedback on my implementation of httpclient. I am not so strong with error handling so I want to improve. My thought process behind this was that IOExceptions can be ...
2
votes
2answers
63 views

Is this right way to implement Abort, Retry and Ignore activity pattern?

I've a bunch of sequential activities. These are long running. Once an activity is complete, it can't be rolled back. Now something deep down the line fails. Now I've few options Report this to end ...
1
vote
1answer
53 views

PHP - Is this proper use of exceptions for error handling within classes?

I've searched plenty on this topic and have gotten a lot of good (but different) results. Some of the results weren't quite related and it does seem to be a matter of preference in the end, but I'm ...
1
vote
1answer
69 views

Could this php error/exception handling be better?

I'm VERY new to error/exception handling, previously just echoing everything to screen, and am trying to really clean up my code. My goal was to log everything but only show the user a friendly ...
0
votes
2answers
54 views

extending Exception to allow for auto appending class name on exception message

Got this idea from the php.net website on extending exceptions. The main thing I wanted with this was to have the exception name auto imprinted on the exception message, so I wouldn't have to write it ...
2
votes
1answer
51 views

How can I improve CreateGenre() function?

I use this function in my wordpress site to add genres to an album: What is it that makes this code so bulky? Is it have for the server or it just looks like? /** * Creates a genere. If one already ...
2
votes
3answers
116 views

Exception handling continuing the excecution

This code is for continuing the execution after an exception, and this is ugly: int step=0; do{ try{ switch(step) { case 0: ...
4
votes
2answers
125 views

Asserting when cleanup is required

I've been looking at ways to use asserts in programs that must do some kind of cleanup on fatal errors, and have arrived at the following pattern (PROJECT being replaced by the name of the project): ...
6
votes
5answers
491 views

How to reduce the amount of try/catch in my code?

I have the following code that checks for three different properties. Unfortunately each call can throw up to four exceptions that I all have to catch. Can I some how make the code more readable by ...
1
vote
1answer
82 views

Learning Simple Operating System Tools: Experienced Tips?

Operating system code, I've noticed, has two outstanding properties: 1. It's everywhere, and vitally important to functional software 2. It has *lots* of exceptions. Please give me some pointers on ...
2
votes
2answers
139 views

Is it acceptable to pass an Exception into a function that then may or may not throw it?

I am still getting the hang of Exception Handling in PHP; Here is the scenario where I am using the convention: There are times where I have a SQL query that I need to turn into an object, so I wrote ...
4
votes
6answers
365 views

Could this ExecuteScalar call be written better?

I came across this code in our project today. Where possible I'm trying to leave the code base in a better shape than I found it, as I go along, and this method jumped out at me for a number of ...

1 2
15 30 50 per page