473,888 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enums & Flags

I am running loop with calls different functions such as
SetHomeDrive, AddUserToGroup etc. Now if any of the
functions fails, I am just catching and throwing a new
error like throw new Exception("Fail ed to Set Home Drive")
etc.

All these errors which are propelled back to my loop are
then logged to file. Even if an error occours in one ore
more function, the loop continues execution so I deally I
would like to have unique flag for each errror, which can
be OR ed each time an error occurs and finally at the end
of my loop find from the error flag what all errors
occured. How can I acheive this.

Thanks,

Rajesh Abraham Chacko
Nov 15 '05 #1
1 4205
Rajesh,
Generally you should not be raising System.Exceptio n directly, you should
raise a different existing exception that is appropriate for the error or
you should define one of your own.

In this case I would define a new Exception class that has an enum property
for your unique flag. Define this unique flag as an Enum that has the Flags
attribute. Remember to set the values of the Enum to powers of 2: 1, 2, 4,
8, 16, 32, 64, 128... This exception class should derive from
System.Applicat ionException. At the very least I would give it a constructor
that accepted this Enum, and a text string. In the main loop I would catch
this type of Exception, Or-ing the value with an accumulator.

See "Error Raising and Handling Guidelines" in the Design Guidelines for
Class Library Developers.

http://msdn.microsoft.com/library/de...guidelines.asp

Hope this helps
Jay

"Rajesh Abraham" <ch******@hotma il.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
I am running loop with calls different functions such as
SetHomeDrive, AddUserToGroup etc. Now if any of the
functions fails, I am just catching and throwing a new
error like throw new Exception("Fail ed to Set Home Drive")
etc.

All these errors which are propelled back to my loop are
then logged to file. Even if an error occours in one ore
more function, the loop continues execution so I deally I
would like to have unique flag for each errror, which can
be OR ed each time an error occurs and finally at the end
of my loop find from the error flag what all errors
occured. How can I acheive this.

Thanks,

Rajesh Abraham Chacko

Nov 15 '05 #2

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

Similar topics

13
9564
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could change and lead to memory corruption. I didn't see how this was possible. He claims that if a dll built for a program is built with different compiler settings than the launcher program, the enum size could change. The only way I could figure...
3
14735
by: Mike Scott | last post by:
What is the best way to index an array by an enum. Pascal has a nice feature in that arrays can be indexed by an enum, for example type ButtonType = ( Left, Middle, Right ) ; var buttons : array of Button ; ....
2
2504
by: Kyle Novak | last post by:
What I want to do is take the values of an enum and have a related textual description for each item. For example, if I have an enum declared as the following... public enum EqualityOperator { Equal = 1, LessThan = 2, GreaterThan = 4,
5
12537
by: DMitchell | last post by:
Is there any way of getting a public enumeration to be generated into a web service proxy?
7
1555
by: Bit Twiddler | last post by:
I have a home grown bit vector and I keep oscillating between what I use access individual bits. For example, is is better to do this: const int BIT_1 = 1; const int BIT_2 = 2; .... int my_bits;
9
2792
by: userblue | last post by:
Hi Does anyone know if there is a way to define what is effectively a single globally visible, enumerated list whilst actually defining the entries across several different modules? or somehow do a similar thing with macros. Details: I have a c project to fit into a small microprocessor and need to save some ram. I have a significant number of flags all over the place that currently use whole byte storage. I thought if I had a way to...
3
1721
by: J055 | last post by:
Hi The function below accepts an Enum value 'AccountRoles' and should return an array of Permissions which is also an Enum. When the AccountRoles is AccountRoles.Administrator it should always return the full list of values from the Permissions enum. Is there a clean way to do this? public static Permissions GetPermissions(AccountRoles role) {
2
1478
by: Rain | last post by:
Im using C#3.0 and in my book of words it tells me that when I use the I should be able to call ToString() on a combined enumeration and have it emit a series of strings. IE public enum myEnum {
0
734
by: Cousin Stanley | last post by:
I've never had any problems at all with message threading using xpn .... Since I've always used Keep SubThread instead of Watch SubThread, I have no personal experience with the watch flags .... When using keep flags, new messages in a thread do have to be toggled on, so perhaps the the watch flags behave the same .... Such toggles are easily achieved by setting desired keystrokes
0
9800
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
10778
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10886
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9597
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
7990
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
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
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
3
3252
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.