Click here to Skip to main content
15,880,891 members
Home / Discussions / C#
   

C#

 
QuestionA similar action to a try catch statement? Pin
Kuira10-Nov-05 11:49
Kuira10-Nov-05 11:49 
AnswerRe: A similar action to a try catch statement? Pin
Christian Graus10-Nov-05 12:42
protectorChristian Graus10-Nov-05 12:42 
GeneralRe: A similar action to a try catch statement? Pin
Kuira10-Nov-05 13:25
Kuira10-Nov-05 13:25 
GeneralRe: A similar action to a try catch statement? Pin
Christian Graus10-Nov-05 13:27
protectorChristian Graus10-Nov-05 13:27 
GeneralRe: A similar action to a try catch statement? Pin
Kuira10-Nov-05 13:46
Kuira10-Nov-05 13:46 
GeneralRe: A similar action to a try catch statement? Pin
Leslie Sanford10-Nov-05 18:47
Leslie Sanford10-Nov-05 18:47 
GeneralRe: A similar action to a try catch statement? Pin
Kuira13-Nov-05 12:15
Kuira13-Nov-05 12:15 
GeneralRe: A similar action to a try catch statement? Pin
Leslie Sanford13-Nov-05 13:11
Leslie Sanford13-Nov-05 13:11 
Ok, my eariler suggestion doesn't work because the test methods have different signatures.

One approach would be to abandon using the boolean and just use exceptions:

public void Test(input data, input tablename, output conflictions)
{
    Test1() //connect to database
    Test2(tablename) // checks if the table is not locked at the moment
    Test3(data, tablename) // checks if the data is already inserted
    Test4(data, tablename, conflictions) //validates if we insert this data and hits a number of constraints
}

private void Test1()
{
    // Do connection stuff...

    if(unableToConntect)
    {
        throw new ApplicationException("Cannot connect to database.");
    }
}


You would probably want to use your own exception class derived from Exception or ApplicationException that contains information about the failure.

If throwing an exception from the Test method is unacceptable, you could catch the exception in the method itself, and do whatever is appropriate there, or maybe even take some action and rethrow the exception.
GeneralRe: A similar action to a try catch statement? Pin
Kuira13-Nov-05 17:05
Kuira13-Nov-05 17:05 
GeneralRe: A similar action to a try catch statement? Pin
Leslie Sanford13-Nov-05 17:37
Leslie Sanford13-Nov-05 17:37 
GeneralRe: A similar action to a try catch statement? Pin
Kuira14-Nov-05 11:53
Kuira14-Nov-05 11:53 
QuestionParsing an XML string Pin
Ravi Bhavnani10-Nov-05 11:49
professionalRavi Bhavnani10-Nov-05 11:49 
AnswerRe: Parsing an XML string Pin
Ravi Bhavnani10-Nov-05 12:09
professionalRavi Bhavnani10-Nov-05 12:09 
Question.net 2.0 Membership in Windows Applications? Pin
MightyJoe10-Nov-05 11:11
MightyJoe10-Nov-05 11:11 
QuestionDrag Drop within a Control Pin
miah alom10-Nov-05 10:41
miah alom10-Nov-05 10:41 
QuestionByValue parameter is not used Pin
Seraphin10-Nov-05 10:08
Seraphin10-Nov-05 10:08 
AnswerRe: ByValue parameter is not used Pin
Leslie Sanford10-Nov-05 11:02
Leslie Sanford10-Nov-05 11:02 
GeneralRe: ByValue parameter is not used Pin
Seraphin10-Nov-05 13:14
Seraphin10-Nov-05 13:14 
GeneralRe: ByValue parameter is not used Pin
Leslie Sanford10-Nov-05 16:44
Leslie Sanford10-Nov-05 16:44 
QuestionOkay, i gotta question - who wants to look? Pin
Anthony Mushrow10-Nov-05 9:54
professionalAnthony Mushrow10-Nov-05 9:54 
AnswerRe: Okay, i gotta question - who wants to look? Pin
Christian Graus10-Nov-05 13:35
protectorChristian Graus10-Nov-05 13:35 
QuestionPackage load error in VS2005? Pin
TheGreatAndPowerfulOz10-Nov-05 8:38
TheGreatAndPowerfulOz10-Nov-05 8:38 
QuestionLabel question Pin
Stanciu Vlad10-Nov-05 7:52
Stanciu Vlad10-Nov-05 7:52 
AnswerRe: Label question Pin
Anthony Mushrow10-Nov-05 8:01
professionalAnthony Mushrow10-Nov-05 8:01 
GeneralRe: Label question Pin
Stanciu Vlad10-Nov-05 8:35
Stanciu Vlad10-Nov-05 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.