473,699 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Method of Error Handling

I'm totally new to Python error handling. I see there are many, many
ways to handle errors in Python. What is the standard accepted 'best
practice'?

I will be writing unit tests for every module, and translating into
different languages. If I call everything an 'Exception', I can easily
load the messages from a text file... if I finely divide all the
errors up into separate error classes, I can't load from a text file
at run time. Or maybe I can, and I just don't see it.

Thanks for your time!

--Kamilche
Jul 18 '05 #1
1 1645
In article <88************ **************@ posting.google. com>,
Kamilche <kl*******@home .com> wrote:

I'm totally new to Python error handling. I see there are many, many
ways to handle errors in Python. What is the standard accepted 'best
practice'?

I will be writing unit tests for every module, and translating into
different languages. If I call everything an 'Exception', I can easily
load the messages from a text file... if I finely divide all the
errors up into separate error classes, I can't load from a text file
at run time. Or maybe I can, and I just don't see it.


Read through the code in /Lib/ -- you'll see many examples.
--
Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
9379
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
2
1769
by: Max | last post by:
Sometimes I get this error when testing web.mail: The server rejected one or more recipient addresses The server response was: 473 kjhg@Kjhg.com relaying prohibited. You should authenticate first This goes away when I simply put a try/catch around sending email, but I'm wondering if I can use this to my advantage -- come back to the user saying their email is invalid, try again? I'm asking if this is a good method, since I'm a little...
4
1997
by: Sandy | last post by:
Hello - I read an interesting article on the web wherein the author states he doesn't handle too many errors at page level, but handles them at the application level. He further goes on to show how error logging can be incorporated using a Sql Server log with an additional text log in case Sql Server was down. My inclination after reading the article is to use Try-Catch-Finally as little as possible (tends to slow things if you have...
4
7611
by: James Radke | last post by:
Hello, I am looking for guidance on best practices to incorporate effective and complete error handling in an application written in VB.NET. If I have the following function in a class module (note that this class module represents the business layer of code NOT the gui layer): Public Function Test(ByVal Parm1 As Integer, ByVal Parm2 As Integer) As SqlDataReader ' Declare the SQL data layer class Dim oSQL As New...
8
1566
by: SStory | last post by:
When I right a class, I am wondering what are the best practices for error handling? Do I try..catch and trap the error and if so what do I do with it? Because most likely the class user will want to know the information in the exception.... That being the case do I just not catch it and let the user of the class catch it and get all the information? I know I could catch it and throw my own, but I'd have to tell them the same
6
2094
by: RonL | last post by:
What is the recommended best technique for handling errors/exceptions in ASP.Net. I've read about the following techniques: 1. Try/Catch 2. Page_Error 3. Application_Error in the glabal.asax 4. Custom errors in Web.Config.
5
1734
by: csgraham74 | last post by:
Hi guys, Basically i have been developing in dotnet for a couple of years but ive had a few issues in regards to error handling. For example - I have a class that i call passing in a stored procedure and connection string as a path. My method returns a dataset. In my SP i have an output parameter which tells me whether the SP select is successful or not. If i get a error code passed back then i throw an exception this then returns...
0
1246
by: joshfink | last post by:
Hey guys, I am writing an application where I want to follow the best practices on error handling. This is what I have: I created an enum for various issues that could happen within the DAL... INSERTFAILED, INSERTSUCCESSFUL etc... I am setting this enum to a property of the dal for the object to access after the dal is done with whatever method I call... get, getAll, update, insert, delete, etc... The object can then access...
5
3024
by: Conrad Lender | last post by:
I'd like to hear your opinions about the appropriate way to deal with non-critical errors that can occur in user-defined functions. For example, an application chooses to extend String.prototype with a format() method similar to sprintf(). Several formats (%d, %f, etc) are supported, but %z would be invalid. During the parsing of the format string, the function encounters an invalid format which (most likely) was caused by a programmer...
0
8691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8887
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7755
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6536
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2351
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.