Results 1 to 4 of 4

Thread: Try catch Block

  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Unanswered: Try catch Block

    Hello,
    Beginner here with a basic question
    When do you use a Try and catch block in a program?Do you have to use try catch to make your pgm look more professional ?

  2. #2
    Join Date
    Dec 2003
    Location
    chennai
    Posts
    27

    Post Re: Try catch Block

    try catch block is used to avoid termination of program in the runtime
    try catch block is mainly used for database application
    its nice way to use database application b'coz if any automatic or any runtime error causes termination of a program then there might be chances of crash in the databases

    so if any error raised means we can catch in catch block and we can close the database in the catch block


    Originally posted by marge
    Hello,
    Beginner here with a basic question
    When do you use a Try and catch block in a program?Do you have to use try catch to make your pgm look more professional ?

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    Actually try-catch-finally block is used to catch any errors/exceptions. It prevents your application from terminating unexpectedly and allows you to handle the errors.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Actually try-catch-finally block is used to catch any errors/exceptions. It prevents your application from terminating unexpectedly and allows you to handle the errors.
    That's pretty much it in a nutshell. Another specific use not mentioned that I like to apply try..catch(try..except) blocks for is datatype checking. eg:

    try
    casttosomething(variable)
    except
    messagebox(invalid datatype, please enter a valid type)
    end

    Something like that checks to make sure a user input was a valid type, quite useful for data integrity.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •