I am calling a function that requires an Exception which you normally get
from a Catch ( Catch(Exception exc)).
But I have a message I am trying to pass to this funtion, but since it
requires an Exception object, I can't just send the message.
I need to create an Exception object and make the exc.Message field equal to
my message and then pass the new object to the function.
Is there a way to do this other than forcing a Catch?
Thanks,
Tom 3 1849
tshad wrote:
I am calling a function that requires an Exception which you normally get
from a Catch ( Catch(Exception exc)).
So this function is like:
public void someFunc(Except ion e)
?
But I have a message I am trying to pass to this funtion, but since it
requires an Exception object, I can't just send the message.
I need to create an Exception object and make the exc.Message field equal to
my message and then pass the new object to the function.
Is there a way to do this other than forcing a Catch?
someFunc(new Exception("Mess age"));
Unless I'm misunderstandin g what you mean.
Some simple sample code would go a long way towards clearing up any confusion.
Chris.
As Chris indicated, Exception is a class just like any other class. Simply
create a new instance of Exception and set whatever properties you want,
then pass it into the method call as the parameter, ex:
Exception ex = new Exception();
ex.Message="bla h, blah";
MyMethod (ex);
--peter
"tshad" <tf*@dslextreme .comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>I am calling a function that requires an Exception which you normally get from a Catch ( Catch(Exception exc)).
But I have a message I am trying to pass to this funtion, but since it
requires an Exception object, I can't just send the message.
I need to create an Exception object and make the exc.Message field equal
to my message and then pass the new object to the function.
Is there a way to do this other than forcing a Catch?
Thanks,
Tom
On May 28, 1:16*pm, "tshad" <t...@dslextrem e.comwrote:
I am calling a function that requires an Exception which you normally get
from a Catch ( Catch(Exception exc)).
But I have a message I am trying to pass to this funtion, but since it
requires an Exception object, I can't just send the message.
First of all Exception is just another class in the framework, you can
create instances of it as you please.
most probably you are calling a logging method.
You can simply say MyFunction ( new Exception("eere er"));
I advise you to do so though.
Exception has other properties (StackTrace, etc) that are usually used
to find more info about an error. You have to try your method in case
it expect those fields populated.
Also you could create an override of that method that simply receive a
String. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bil Muh |
last post by:
Esteemede Developers,
I would like to Thank All of You in advance for your sincere guidances.
I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.
Briefly
--------------------------------------------------------------------------------------------
I need to create dynamically some controls on the forms, and display these
|
by: Richard Skopal |
last post by:
In .NET Windows forms I can create a metafile using this code:
Graphics grph = aControl.CreateGraphics();
IntPtr ipHDC = grph.GetHdc();
Metafile mf = new Metafile(aImgFilePath, ipHDC, EmfType.EmfOnly);
grph.ReleaseHdc(ipHDC);
grph.Dispose();
grph = Graphics.FromImage(mf);
grph.DrawRectangle(aPen, 10, 10, 100, 120);
grph.Dispose();
|
by: Michael |
last post by:
Hello,
I've created an ASP web page where users in our organization can create
Active Directory computer accounts.
The web page is running on a Server 2003 SP1 IIS 6 installation. The
Exchange System Manager is running on the web server and Exchange SP2 has
been installed. The IIS site is configured with Basic Authentication and
users are prompted to enter their Active Directory credentials when
connecting to the site.
|
by: sandy |
last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory',
within my class Directory (Can you already smell disaster?)
Each Directory can have subdirectories so I thought to put these in an
array. The application compiles but aborts without giving me any useful
information.
What I suspect is happening is infinite recursion. Each Directory
object creates an array of Subdirectories each of which has an array of...
|
by: ashishjainism |
last post by:
I am unable to install my windows service and the installutil is throwing the following error:
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the d:\practice in .net\mywindowsservice\mywindowsservice\mywindowsservice\bin\practiceservice.exe assembly's progress.
The file is located at d:\practice in...
| |
by: mohins |
last post by:
I am getting the error while I am trying to connect to Oracle with my code in ASP.NET, this code is working in another machine, but it fails in my laptop, giving the below error.
Could not create an environment: OCIEnvCreate returned -1.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
...
|
by: TG |
last post by:
Hi!
I have an application in which I have some checkboxes and depending
which ones are checked those columns will show in the datagridview
from sql server or no.
After that I have 2 buttons:
1) export to excel button exports the visible columns from the
datagridview to excel (this works fine)
|
by: Mark B |
last post by:
I want to display a pre-designed graphical 'performance badge' on certain
webpages (round, about 2cm diameter) next to a salesperson's details.
I have a function, fGetPerformanceGrade(SalesPersonID as Long) as String to
retrieve that salesperson's grade (e.g. A+, A, A-, B+, B... D). Also one
other function, fGetMonthlySales(SalesPersonID as Long) as String to get
their sales figure, e.g. "$87K".
I want web visitors to be able to click...
|
by: illegal.prime |
last post by:
Hi all, I'm getting unexpected results when trying to preload
assemblies into an AppDomain I'm creating. Upon creation of the
AppDomain - I attach an AssemblyResolve to both my current AppDomain
and the new AppDomain I create.
I copy all the assemblies/dlls into a new directory and then try
loading them all into the new AppDomain using the following:
private void LoadAssembliesFromDirectory(AppDomain appDomain, string
directory)
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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,...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |