Which Error Handling Model Is More Robust?

Sep 13, 2009

I'm kind of torn between these two error-handling models:Create a boolean Error and a string ErrorMessage property for your object. Catch all exceptions internally in the object's methods and pass the messages along using conditional logic from the caller, ie:

[Code]...

To me, it seems like the same amount of code either way, except that you have property code for the Error and ErrorMessage properties. However, you also can tell when an error occurs without having to check for exceptions. Which pattern should I go with?

View 6 Replies


ADVERTISEMENT

Asp.net - An Error Of Report Document Object Model?

Apr 28, 2011

I created a report using report document object model in visual studio 2008 with vb.net. But I found one error. When the user clicks export button in client side, the following error will show. But the first time is OK before the user clicks export button.

Logon failed. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Login failed for user 'zanhtet'. SQL State: 42000 Native Error:

This is calling report code.

Dim ReportDocument As New ReportDocument()
Dim ReportPath As String = Server.MapPath("~/ReportDocumentOM/DBlogInRDOM.rpt")

[code]....

View 1 Replies

Robust And Friendly Command Line Tools For .NET?

May 10, 2009

Forget fancy shmancy web stuff. I'm looking for a good .NET CLI argument processing utility, prefer open source code. This is for quick and dirty utilities that need robust and friendly command line argument handling.These are utilities with maybe a day of effort in them. Investing a few days writing good command line handling seems overkill but they really need it.Features I like in command line handlers. I'd be thrilled with any open source project that had 2 or 3 of the following.A consistent syntax, posix had a nice command line standard, but not necessarily posix.Ability to provide short names for agruments. E.g. "msbuild /t" == "msbuild /target".It supports good command line parsing then gets out of the way. I want some that my code uses, not something that imposes a pattern on my code e.g. I don't want to have to respond to the presence of an arg with an event, that type of thing. Seperation of concerns is good enough that it's logic can be unit tested. Oh - is it two much to ask for it to read attributes off a class properties (as in .NET configuration classes)? I like the config file overrides in msbuild. I can set properties in a build file, but override on the command line. Built in "show usage". WSF files (csript.exe) have this functionality. I'm not willing to write jscript to get the command line handling though.Not powershell. I can't find anyone in my company who can stand Powershell syntax.

View 4 Replies

VS 2008 Robust Response To Out Of Memory Exception?

Mar 31, 2010

I've noticed that GDI+ and other graphics can crash when asked to deal with very large images, and the crash doesn't always occur where you'd expect it. I am getting this when testing the slide show program I posted to the code bank yesterday. This is the code concerned:

vb.net
Private Sub animTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles animTimer.Tick If infos.Count = 0 Then Exit Su ticks = (ticks + 1)

[code].....

View 14 Replies

Asp.net - Error Handling Using Events, Checking If An Error Happened And React Accordingly?

Sep 8, 2009

I have an object, say Order where if an error occurs, it raises the ErrorOccurred event. If I'm running some code in say, the codebehind for a .aspx page with an public Order registered as WithEvents and I want to check to see if an error has occurred before I run more code, how do I do this? I can't simply check theOrder.ErrorOccurred. Do I have to create a local boolean flag that switches over in the event handler (OnErrorOccurred)?

Example:

Public WithEvents theOrder As New Order
Public Sub DoStuff()
theOrder.DoSomething()
If theOrder.ErrorOccurred Then

[code]....

View 3 Replies

Error Handling Should Be Used In .NET

Jun 15, 2010

What error handling should be used in VB.NET? Should one use the "On Error Goto ErrorHandler Exit Sub ErrHandler ... End Sub" pattern or should you use the "try {... } catch {...} finally {... }" pattern?

View 4 Replies

.net - Handling Error Strings?

Aug 14, 2009

In my vb.net application if I have a known set of Error Strings i.e.

Failed because I don't know about it
Failed because I know about it but I can't find it
Failed for another reason

[code].....

View 6 Replies

Error Handling With Messagebox

May 21, 2011

I am just doing a bit of error handling. I am just check to make sure that a user has selected an option within a combo box (named cbtitle1) and if option has not been selected throw an error message to tell the user.this if statement is within a save button which once a user click save this error checking runs first then if combo box has an option selected the save goes ahead else it throws an error.I can stop the save function OK but I wanted to put a error icon in with the message box but I get an error when I add it.[code]

View 3 Replies

Error Handling. When And When Not It's Needed?

Dec 21, 2009

Obviously error handling is a major factor in making a good application. If a error happens letting a user know what has gone wrong.But some times error handling may(i think) not be needed. Example.

Private Sub RemoveCheckedl()
Try
For Each Item As ListViewItem In lst.CheckedItems[code]....

also when error handling it's could to think about what type of errors could be made.

Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

even though this catches the error and displays a msg, it may not be a great message for the user so he/she can understand.

View 21 Replies

Handling Error Within An Executable

Jan 29, 2010

I am working on an executable to load set of data into databases.I will be running it as a windows service. I will be doing several different checks to see if the fields exists in the incoming files. When i do the checks using if statements.I would like to stop processing when a major error occurs or when any thing is interrupted Like say windows crashed. I would like to create an error file with the error message in it for that particular file. I would be monitoring error folder everyday to check if there are any errors.

View 1 Replies

Use Custom Error Handling?

Mar 8, 2010

When debugging a program, instead of doing this on EVERY piece of code:

Try
MyFunction()
Catch ex as Exception
MsgBox(ex.Message)
End Try

Is there a way to apply that to everything error I encounter without writing it on every function/sub/etc?

View 3 Replies

.net - Error Handling Message Types?

Mar 13, 2012

I am using try..catch for error handling. I am getting the message displayed as

messagebox.show (ex.tostring)

But it gives very long message.Is it possible just to get only the actual error or I could give my own modified message, based on what ex contains?

View 5 Replies

C# - Error Handling In DTS Package Execution Using .NET

Oct 20, 2010

I am executing a SQL Server 2000 DTS package using C# by following the code from this article [URL]. once the package is executed I am looping through each step to find out if any step has failed and get info about error if it has failed. I also use this information to find out if the package has succeeded or not (package failed if anyone step has failed).

[Code]....

View 1 Replies

C# - How To Design Overall Error Handling System

Jul 22, 2010

I am looking at implementing a Web Service API for our product. I have figured out how you go about the general architecture/fault handling within WCF. My question is a more general one of how to design the overall error handling system. For example I have a method called SaveCompany (companyobject). Each company name needs to be unique. Say you tried to save a second company called "ABC Inc.". Would you expect to get back a fault named "DuplicateCompanyFault", or would you expect to get back an error code, or something else? I guess the root of my question is would you prefer to receive faults to handle, error code, or some combination? These services are going to be consumed by multiple different entities outside our company on multiple non-.NET platforms.

View 2 Replies

Error Handling In Search Button

Aug 26, 2011

I am creating function for search data using textbox and button. i want to put an error handling in my code which if the data was not found then it will appear in message box "Data is not found. For your info i am using visual studio and sql 2005. Here is my code and i also attach my picture

Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Me.StaffBindingSource.Filter = "NAME = '" & Me.txtsearch.Text & "'"

[Code].....

View 1 Replies

Error Handling Procedure Calls?

Oct 14, 2009

I have an issue with handling errors in procedure calls in VB6.

View 6 Replies

Error Handling Using Reflection And Obfuscation?

May 4, 2011

I use a standard error handling routine in my methods that looks like the following:

Try
Cursor.Current = Cursors.WaitCursor
Cursor.Current = Cursors.Default

[code].....

View 1 Replies

Error Handling When Using VB 2010 Express?

Jun 3, 2012

I used the following code(with bug):

Code:
For n = 0 To 100
If saveLine(n).Substring(0, 8) = "heading:" Then
cboSelect.Items.Add(saveLine(n).Substring(8))
End If
Next n

The For loop only ran 5 times. It turned out that saveline(5) was shorter then 8 characters, so I changed the code which solved the problem:

Code:
For n = 0 To 100
If saveLine(n).Length > 8 Then

[code]....

VB 2010 neatly exits the for loop when the bug occurs. In this case it was easy for me to pick up the bug, because the combo box was not properly populated. What if it was not obvious that the for loop did not complete? It is quite scary to think that bugs like this are not displayed at run time.

View 4 Replies

Generic Error Handling Class?

Jan 10, 2012

We are developing an application for our shop floor. This program will be tracking material through the shop and we need to capture any errors the program generates, but we don't need to stop the program for all errors. I have some code to do a screen capture and put it in a database with exception.tostring data for debugging.

What we would like to do, is create an exception from the base class, but provide additional properties to allow us to set a severity and a user friendly error message. I would like to encapsulate this in a class that we would call in the catch of a try/catch, set the properties on the class, have the class record the data to the database, then raise the exception to the main program to display only the user friendly message and severity. The main program would then determine the severity and based on the severity stop the program or just display a discreet msg and continue to process.

Does anyone have an example of a custom exception class derived from exception that does something similar, or if I heading in the wrong direction, does anyone have a better solution?

View 5 Replies

Handling Connection Timeout Error?

Dec 13, 2009

Sometimes when my server is down or busy, I get an error saying "connection timeout" while connecting to MySQL. But with the error the program also crashes. My question is how can I prevent crashing, it would be better to show a msgbox when this happens. (visual basic 2010)here is a screenshot of the error

I use this,
Dim connStr As String = "Database=mydatabase;" & _
"Data Source=datasrc;" & _

[code].....

View 2 Replies

Looking For Examples Of Error Handling Code

Sep 14, 2009

I have a routine that is called when an unhandled exception occures.It is called by the MyApplication_UnhandledException method in applicationEvents (which handles Me.UnhandledException)

I am looking for some code that manages disects the data provided to generate information that is of benefit to the debugging team.

View 16 Replies

VB Express Beginner Error Handling

Aug 20, 2010

I just need a good nights sleep, but Im simply reading through a file (2010 data) and for selected teams, accessing the corresponding data for the previous year (2009 data), which is held on a separate file. (I painstakingly input all the 2009 data manually)

ds1.Clear()
cmd1.CommandText = "SELECT * FROM Teams WHERE Team = ?"
cmd1.Parameters.Add(NewSqlCeParameter("Team", (ds.Tables(0).Rows(x) ("Team"))))
cmd1.Prepare()
cmd1.ExecuteNonQuery()

[Code]...

View 8 Replies

VS 2005 Error Handling Scope?

Mar 10, 2011

plain how error handling scope works. What I mean by that is if I have a sub called ImportData and in there I have a for loop to go through a list of files and in the for loop I call another sub routine called CheckData. All have catch error in. If a sub has a catch error in where does it go from its call.

Private Sub ImportData
Dim iLoop as Int16
Try

[code].....

View 10 Replies

VS 2010 AppActivate Error Handling?

Dec 17, 2011

I am trying to add some error handling for AppActivate if any error occurs.I initially tried using a try statement and cancelling the sub that calls the function where my AppActivate code is, but that didn't work.I have tried looping it, changing values and everything I know. I have Googled and nothing :S

Here is my I have removed all the error handling I tried to implement, however, this commented msgbox I would like to be included (that is, possible to execute) in any methods you present.

[Code]...

View 1 Replies

VS 2010 Unable To Do Error Handling

Feb 21, 2011

I was just wondering if it is considered overkill to add:

[code]...

To every sub in your project. And what would be the side effects of this if any.

View 6 Replies

C# - Accessing Office Word Object Model Through Asp.net Results In "failed Due To The Following Error: 80070005 Access Is Denied."

Aug 13, 2010

I have developed a website that allows users to upload office documents then uses the office object model to convert the document to an HTML file that it then displays in an iFrame. I have, of course, included references to Office.interop.word, and the site works fine on my development machine. When I uploaded it to my production server the site functions fine until I try to upload a document. I initially got a similar error that said "COM object not registered". I realized that Word wasn't installed on my production server. So I installed word and now when the server tries to access the word object model I receive the following error:

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I searched the registry for the corresponding CLSID and found a corresponding folder. I added full control to the IUSR_ account and due to the persistence of the error I eventually added full control to "everyone" and ensured these permissions inherited down to the rest of the folder. I then added full control to IUSR_ and again eventually added full control to "everyone" to my microsoft office folder.

I don't know what other permissions to grant and where in order to make this "Access is denied" error go away. I must be granting them in the wrong place, because as far as I know I can't be any more permissive than "Everyone" "Full Control".

View 2 Replies

Error Handling & Copying Folder Structure?

May 2, 2011

Below is a tiny program I modified from an example Microsoft code tutorial. This program simply copies .flac and .mp3 files from one specified folder to another, and if the file is already there it simply does not copy the file. I would like to make 2 changes to the program:

How would I go about making the error handling work (i.e. not crashing the program when an invalid input is made)?Also, a big change I would like to make would be for it to copy the folder structure and all files in the original folder (At the moment, it only copies files that are directly in the original folder, not files that are in folders inside the original folder).

[Code]...

View 2 Replies

Error Handling To Code (Get HTML-from Website)

Feb 20, 2011

Code:

Public Function ScreenScrapeHtml(ByVal url As String) As String
Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url)

[code]...

If it cant reach a URL it will give me this error:

Code:
Webexception was unhandeled:
Dim sr As New StreamReader(objRequest.GetResponse().GetResponseStream())

How I can add some error-handling to this code? Like if it cant reach a URL.

View 3 Replies

Experiencing Error Handling Although No Input Errors

Feb 12, 2011

I'm using Try/Catch blocks for a program calculating payroll and commission. I've dim'd my variables, and I've parsed them inside my Try/Catch blocks. It appears as if my Try/Catch blocks have been coded correctly. However when in run-time, my format exceptions will show regardless if I provided a correct input.[code]Is there an issue with my programming? Or could there be a property I'm over-looking for my text boxes? I'm stuck.

View 5 Replies

Experiencing Error Handling Although No Input Errors?

Feb 20, 2012

Experiencing error handling although no input errors?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved