473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Exceptional Handling

440 256MB
Hi ,

Whether we have to write the try/catch for each method of the class or it is sufficient to write in the main execution of the functionality call.

Is Error Handling and Exceptional Handling same or different?

Thanks in advance
PSB
Feb 28 '07 #1
1 1252
bartonc
6,596 Expert 4TB
Hi ,

Whether we have to write the try/catch for each method of the class or it is sufficient to write in the main execution of the functionality call.

Is Error Handling and Exceptional Handling same or different?

Thanks in advance
PSB
There is such a thing as "over wrapping" (enclosing too much functionality in the try block). In practice, it's best to let python catch there errors at first. Then wrap code that you expect to get errors from and know how to handle elegantly. For example:
Expand|Select|Wrap|Line Numbers
  1. emplyList = []
  2. try:
  3.     a = emplyList[0]
  4. except IndexError:
  5.     print "the list is empty"
It is also important to include the error type that you are expecting so that (say) a memory full error is not cought by mistake.
Mar 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: makuchaku | last post by:
Hi all I'm facing a strange problem in C++ exceptions. If an error occurs in a class, throw() is used. But whenever that happens, the object is destroyed. In a nutshell, accessing the...
0
by: LongRunner | last post by:
Hihi, i am writing utilities classes using C#. The utilities contain my own exceptional classes. Until now, my design about the exceptional classes is that: I have my expceitonal class and...
9
by: Henry | last post by:
I am puzzled by something. I have a program foo.cs it has a reference to an assembly bar.cs. The latter intentionally performs a divide by zero. The former has a try/catch pair for the offending...
0
by: kendf | last post by:
As a beginner, I using .Net SDK v1.1 for command line compilation. I have a problem to compile the source code of MS Exceptional Management Application Block, downloaded from MS official web...
6
by: kids_pro | last post by:
Hi there, using(StreamWriter wr = new StreamWriter(filename,false,Encoding.UTF8,1024)){} Will the line above throw any exception when it can't create file? What is the best way to capture it...
3
by: clintonb | last post by:
Some programmers, and even Microsoft documents, say you should only throw exceptions for exceptional situations. So how are others handling all the other unexceptional errors? How are you...
4
by: lovecreatesbea... | last post by:
Is the following code (without any code at lines x and x + 3) correct? Is it better to call exit() or re-throw the exceptions at line x and line x + 3?. What is the better code should we place at...
1
by: Hicham Mouline | last post by:
Hello, I am looking for an example of a constructor, I think, which took the type itself for integral or floating types, and a const-ref for a user-defined non primitive type. I saw this in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.