473,549 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best way to store exception strings

I handle errors in my code by using my own exception class that takes a
number as argument to the constructor, and that number puts a string into
the exception class. The user can then catch the class and display the
string to the user.
Now the strings are all stored inside a map inside the exception class.

But my number of strings are growing and having them all inside the
exception class seems as a bad idear.

Does anyone know a good way to store the strings? (PS I want them compiled
into the code)

Regards Torben
May 16 '06 #1
2 1188
> I handle errors in my code by using my own exception class that takes a
number as argument to the constructor, and that number puts a string into
the exception class. The user can then catch the class and display the
string to the user.
Now the strings are all stored inside a map inside the exception class.

But my number of strings are growing and having them all inside the
exception class seems as a bad idear.

Does anyone know a good way to store the strings? (PS I want them compiled
into the code)


Add the table as a static member to your exception class.
that way there will be only 1 instance of it, and your exception class
instances only need to store the number and / or the text pointer.

I assume that the table is fixed at compile time, so multiple concurrent
lookup operations should be threadsafe.

--

Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"
May 16 '06 #2
I like to have a function to look up the strings. For your problem, it
sounds like the function would have a switch statement and for each case it
will return a different string. This way, you won't have to spend any time
initializing the strings unless there is an actual exception.

"Torben Laursen" wrote:
I handle errors in my code by using my own exception class that takes a
number as argument to the constructor, and that number puts a string into
the exception class. The user can then catch the class and display the
string to the user.
Now the strings are all stored inside a map inside the exception class.

But my number of strings are growing and having them all inside the
exception class seems as a bad idear.

Does anyone know a good way to store the strings? (PS I want them compiled
into the code)

Regards Torben

May 16 '06 #3

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

Similar topics

3
4620
by: Ryan N. | last post by:
Hello, I saw a brief blurb on this somewhere and am unable to recall where... In the context of Security, what are some best practices for handling -storing, locating, retrieving- database OLEDB connection strings? I have typically used a single include file and even considered stuffing the string in a document (XML or otherwise) outside...
12
7697
by: jacob nikom | last post by:
Hi, I would like to store XML files in MySQL. What is the best solution: 1. Convert it to string and store it as CLOB/text 2. Serialize it and store as byte array 3. Flatten it out and create one column per element, each column is VARCHAR Does MySQL has anything special for XML data? Is there any software which helps to store XML data...
2
1417
by: Pekka Henttonen | last post by:
Forgive me this stupid question, but what is the best way to store the length of an object in a database? What datatype would you use? Would it be better to define one of your own?
0
4203
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com....
7
1377
by: Brian Henry | last post by:
I've never stored a program specific connection string in the web.config file before, is there any information on how to store it there and access it from the app and what would be the best way to handle a string like this in asp.net 2.0? thanks!
5
19023
by: Robert W. | last post by:
My app runs perfectly when run in Canada or the U.S. But others are experiencing problems. So I switched my computer to the UK culture and immediately saw a problem. This line was failing: Convert.ChangeType(newdate, propType, null); where propType = System.DateTime It would only fail for dates like this: May 18, 2006 = 5/18/2006 in...
7
19714
by: Tzanko | last post by:
As we all know, there is a 8060 bytes size limit on SQL Server rows. I have a table which requires a number of text fields (5 or 6). Each of these text fields should support a max of 4000 characters. We currently store the data in varchar columns, which worked fine untill our appetite for text fields increased to the current requirement of 5,...
9
7863
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view, what's the best practise for returning a private List<as a property. Consider the example below, the class "ListTest" contains a private "List<>" called "strings" - it also provides a public...
22
3266
by: David T. Ashley | last post by:
I'm writing code which will compile on multiple Windows and multiple *nix platforms. Some will have 64-bit integers, I believe. What is my best option to define platform-independent types such as UINT32 or UINT64? I'm not sure how to sort out the various platforms and integer sizes, and some of it may even vary based on compiler options. ...
0
7548
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...
0
7472
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...
0
7986
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6074
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...
1
5391
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...
0
3518
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...
0
3499
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1083
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.