Search Results

Search found 16643 results on 666 pages for 'exception handling'.

Page 12/666 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Defensive Error Handling

    TRY…CATCH error handling in SQL Server has certain limitations and inconsistencies that will trap the unwary developer, used to the more feature-rich error handling of client-side languages such as C# and Java. In this article, abstracted from his excellent new book, Defensive Database Programming with SQL Server, Alex Kuznetsov offers a simple, robust approach to checking and handling errors in SQL Server, with client-side error handling used to enforce what is done on the server.

    Read the article

  • GWT Javascript Exception in Hosted Mode: Result of expression 'doc.getBoxObjectFor' [undefined] is

    - by holmes
    Anyone ever seen this exception? I'm running in hosted mode on GWT 1.6.4 on a mac. I'm using the AutoSuggest and it's throwing this exception trying to show the popup. It works fine in compiled mode, but obviously hosted mode is rather important. [ERROR] Uncaught exception escaped com.google.gwt.core.client.JavaScriptException: (TypeError): Result of expression 'doc.getBoxObjectFor' [undefined] is not a function. line: 71 sourceId: 1152617088 sourceURL: jar:file:/Users/holmes/.m2/repository/com/google/gwt/gwt-user/1.6.4/gwt-user-1.6.4.jar!/com/google/gwt/dom/client/DOMImplMozillaOld.java expressionBeginOffset: 288 expressionCaretOffset: 307 expressionEndOffset: 313 at com.google.gwt.dom.client.DOMImplMozillaOld.getAbsoluteLeftImpl(Native Method) at com.google.gwt.dom.client.DOMImplMozillaOld.getAbsoluteLeft(DOMImplMozillaOld.java:29) at com.google.gwt.dom.client.Element$.getAbsoluteLeft$(Element.java:86) at com.google.gwt.user.client.DOM.getAbsoluteLeft(DOM.java:646) at com.google.gwt.user.client.ui.UIObject.getAbsoluteLeft(UIObject.java:487) at com.google.gwt.user.client.ui.PopupPanel.position(PopupPanel.java:1015) at com.google.gwt.user.client.ui.PopupPanel.access$5(PopupPanel.java:958) at com.google.gwt.user.client.ui.PopupPanel$1.setPosition(PopupPanel.java:811) at com.google.gwt.user.client.ui.PopupPanel.setPopupPositionAndShow(PopupPanel.java:700) at com.google.gwt.user.client.ui.PopupPanel.showRelativeTo(PopupPanel.java:809) at com.google.gwt.user.client.ui.SuggestBox.showSuggestions(SuggestBox.java:768) at com.google.gwt.user.client.ui.SuggestBox.access$3(SuggestBox.java:738) at com.google.gwt.user.client.ui.SuggestBox$1.onSuggestionsReady(SuggestBox.java:281) at com.google.gwt.user.client.ui.MultiWordSuggestOracle.requestSuggestions(MultiWordSuggestOracle.java:225) at com.google.gwt.user.client.ui.SuggestBox.showSuggestions(SuggestBox.java:640) at com.google.gwt.user.client.ui.SuggestBox.refreshSuggestions(SuggestBox.java:713) at com.google.gwt.user.client.ui.SuggestBox.access$6(SuggestBox.java:705) at com.google.gwt.user.client.ui.SuggestBox$1TextBoxEvents.onKeyUp(SuggestBox.java:678) at com.google.gwt.event.dom.client.KeyUpEvent.dispatch(KeyUpEvent.java:54) at com.google.gwt.event.dom.client.KeyUpEvent.dispatch(KeyUpEvent.java:1) at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65) at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53) at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178) at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52) at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116) at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:90) at com.google.gwt.user.client.ui.TextBoxBase.onBrowserEvent(TextBoxBase.java:193) at com.google.gwt.user.client.ui.Composite.onBrowserEvent(Composite.java:54) at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320) at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299) at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)

    Read the article

  • Spring 3 Controller Exception handler implementation problems

    - by predhme
    I was hoping to implement a single "ExceptionController" to handle exceptions that are thrown in execution of my other controllers' methods. I hadn't specified any HandlerExceptionResolver in my application context so according to the API documentation the AnnotationMethodHandlerExceptionResolver should be started. Verified as such in the source. So I am curious to know why the following isn't working. @Controller public class ExceptionController { @ExceptionHandler(NullPointerException.class) public ModelAndView handleNullPointerException(NullPointerException ex) { // Do some stuff log.error(logging stuff) return myModelAndView; } } @Controller public class AnotherController { @RequestMapping(value="/nullpointerpath") public String throwNullPointer() { throw new NullPointerException(); } } I see in the debug logs that the three default exception handlers are asked for handling of the exception, but nothing is done and I see "DispatcherServlet - Could not complete request". Followed by the user being displayed the stacktrace and a 500 Internal error.

    Read the article

  • How to Avoid Duplicate Key Exception

    - by LifeH2O
    I am using TableAdapter to insert records in table within a loop. foreach(....) { .... .... teamsTableAdapter.Insert(_teamid, _teamname); .... } Where TeamID is the primary key in the table After first run of this loop, Insert throws Duplicate Primary Key found Exception. To handle this, i have done this foreach(....) { .... .... try { _teamsTableAdapter.Insert(_teamid, _teamname); } catch (System.Data.SqlClient.SqlException e) { if (e.Number != 2627) MessageBox.Show(e.Message); } .... .... } But using try catch statement is costly, how to avoid this exception. I am working in VS2010 and INSERT ... ON DUPLICATE KEY UPDATE does not work.

    Read the article

  • Outlook 2003 add-in - Getting COM exception on application shutdown after creating WPF window

    - by Oliver Hanappi
    Hi! I'm developing an outlook 2003 add-in. Until now I used only winforms to display one form, but today I've added a WPF window for more complex stuff. DUe to the WPF window, a COM exception is being thrown when outlook shuts down. Does anybody know why? I need to start a separate thread for the WPF window in single apartment state. Here is the exception: System.Runtime.InteropServices.InvalidComObjectException was unhandled Message="COM object that has been separated from its underlying RCW cannot be used." Source="PresentationCore" StackTrace: at System.Windows.Input.TextServicesContext.StopTransitoryExtension() at System.Windows.Input.TextServicesContext.Uninitialize(Boolean appDomainShutdown) at System.Windows.Input.TextServicesContext.TextServicesContextShutDownListener.OnShutDown(Object target) at MS.Internal.ShutDownListener.HandleShutDown(Object sender, EventArgs e) InnerException: Best Regards, Oliver Hanappi

    Read the article

  • Throw exception from initializer list

    - by aaa
    hello. what is the best way to throw exception from initializer list? for example: class C { T0 t0; // can be either valid or invalid, but does not throw directly T1 t1; // heavy object, do not construct if t0 is invalid, by throwing before C(int n) : t0(n), // throw exception if t0(n) is not valid t1() {} }; I thought maybe making wrapper, e.g. t0(throw_if_invalid(n)). What is the practice to handle such cases? Thanks

    Read the article

  • C# WCF/WebService: Interoperable exception handling.

    - by michael paul
    I understand that WCF will convert an exception into a fault and send it back as a SOAP message, but I was wondering if this is truly interoperable. I guess I'm having a tough time trying to figure out this possible scenario: Client (Java) calls a WCF Service (LoginService). Server checks for proper authorization, user authorization fails. Server throws an UnauthorizedAccessException. WCF converts this into a Fault somehow. (* - See Below As Well) Client has to be able to know how to read this Fault. I guess I'm just having a tough time understanding how this could still be interoperable because it is expecting Java to know how to translate a SOAP Fault that .NET encodes from an UnauthorizedAccessException. Also, how does .NET actually convert the exception to a fault, what goes in as the fault code, name, etc. Some of the things seem to be "duh"s like perhaps the Fault Name is "UnauthorizedAccessException", but I'd rather know for sure than guess.

    Read the article

  • C++, throw exception from initializer list

    - by aaa
    hello. what is the best way to throw exception from initializer list? for example: class C { T0 t0; // can be either valid or invalid, but does not throw directly T1 t1; // heavy object, do not construct if t0 is invalid, by throwing before C(int n) : t0(n), // throw exception if t0(n) is not valid t1() {} }; I thought maybe making wrapper, e.g. t0(throw_if_invalid(n)). What is the practice to handle such cases? Thanks

    Read the article

  • C# Throw Exception on use Assert?

    - by guazz
    I have a system where the employeeId must alway exist unless there is some underlying problem. The way I see it, is that I have two choices to check this code: 1: public void GetEmployee(Employee employee) { bool exists = EmployeeRepository.VerifyIdExists(Employee.Id); if (!exists) { throw new Exception("Id does not exist); } } or 2: public void GetEmployee(Employee employee) { EmployeeRepository.AssertIfNotFound(Employee.Id); } Is option #2 acceptable in the C# language? I like it because it's tidy in that i don't like looking at "throw new Exception("bla bla bla") type messages outsite the class scope.

    Read the article

  • sql exception when transferring project from usb to c:\

    - by jello
    I'm working on a C# windows program with Visual Studio 2008. Usually, I work from school, directly on my usb drive. But when I copy the folder on my hard drive at home, an sql exception is unhandled whenever I try to write to the database. it is unhandled at the conn.Open(); line. here's the exception unhandled Database 'L:\system\project\the_project\the_project\bin\Debug\PatientMonitoringDatabase.mdf' already exists. Choose a different database name. Cannot attach the file 'C:\Documents and Settings\Administrator\My Documents\system\project\the_project\the_project\bin\Debug\PatientMonitoringDatabase.mdf' as database 'PatientMonitoringDatabase'. it's weird, because my connection string says |DataDirectory|, so it should work on any drive... here's my connection string: string connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\PatientMonitoringDatabase.mdf; " + "Initial Catalog=PatientMonitoringDatabase; " + "Integrated Security=True"; what's going on here?

    Read the article

  • Should I throw my own ArgumentOutOfRangeException or let one bubble up from below?

    - by Neil N
    I have a class that wraps List< I have GetValue by index method: public RenderedImageInfo GetValue(int index) { list[index].LastRetrieved = DateTime.Now; return list[index]; } If the user requests an index that is out of range, this will throw an ArgumentOutOfRangeException . Should I just let this happen or check for it and throw my own? i.e. public RenderedImageInfo GetValue(int index) { if (index >= list.Count) { throw new ArgumentOutOfRangeException("index"); } list[index].LastRetrieved = DateTime.Now; return list[index]; } In the first scenario, the user would have an exception from the internal list, which breaks mt OOP goal of the user not needing to know about the underlying objects. But in the second scenario, I feel as though I am adding redundant code. Edit: And now that I think of it, what about a 3rd scenario, where I catch the internal exception, modify it, and rethrow it?

    Read the article

  • sql exception when transferring project from usb to c:\

    - by jello
    I'm working on a C# windows program with Visual Studio 2008. Usually, I work from school, directly on my usb drive. But when I copy the folder on my hard drive at home, an sql exception is unhandled whenever I try to write to the database. it is unhandled at the conn.Open(); line. here's the exception unhandled Database 'L:\system\project\the_project\the_project\bin\Debug\PatientMonitoringDatabase.mdf' already exists. Choose a different database name. Cannot attach the file 'C:\Documents and Settings\Administrator\My Documents\system\project\the_project\the_project\bin\Debug\PatientMonitoringDatabase.mdf' as database 'PatientMonitoringDatabase'. it's weird, because my connection string says |DataDirectory|, so it should work on any drive... here's my connection string: string connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\PatientMonitoringDatabase.mdf; " + "Initial Catalog=PatientMonitoringDatabase; " + "Integrated Security=True";

    Read the article

  • Return a dynamic string from std::exception's `what`

    - by Shtééf
    I'm convinced at this point that I should be creating subclasses of std::exception for all my exception throwing needs. Now I'm looking at how to override the what method. The situation that I'm facing, it would be really handy if the string what returns be dynamic. Some pieces of code parse an XML file for example, and adding a position or line number to the error message is useful to me. What I'd like to know: what returns a const char *, which implies any catcher is likely not going to free the string. So I need some other place to store the result, but where would that be? (I need thread-safety.) what also includes throw() in its signature. While I can prevent my what from throwing anything, it seems to me that this method really isn't intended for anything too dynamic. If what is not the right place, then where should I be doing this instead?

    Read the article

  • Unable to catch exception from Activator.CreateInstance.

    - by Patrik Hägne
    OK, I admit it this code will just look weird to you, and that's because it is weird. This is just code to reproduce the behavior, not code I want to use. class Program { static void Main(string[] args) { try { Activator.CreateInstance(typeof(Func<int>), new object[] { new object(), IntPtr.Zero }); } catch { Console.WriteLine("This won't print!"); } Console.Write("Actually this will not print either!"); Console.ReadLine(); } } No matter what exception type I try to catch (the actual exception thrown is an ArgumentException as far as I can tell) the code inside the catch block will not execute. Actually execution will just stop at the Activator.CreateInstance-line.

    Read the article

  • VS C++ throwing divide by zero exception after a specific check

    - by Dr. Monkey
    In the following C++ code, it should be impossible for ain integer division by zero to occur: // gradedUnits and totalGrades are both of type int if (gradedUnits == 0) { return 0; } else { return totalGrades/gradedUnits; //call stack points to this line } however Visual Studio is popping up this error: Unhandled exception at 0x001712c0 in DSA_asgn1.exe: 0xC0000094: Integer division by zero. And the stack trace points to the line indicated in the code. It seems like VS might just do this with any integer division, without checking whether a divide by zero is possible. Do I need to catch this exception even though the code should never be able to throw it? If so, what's the best way to go about this? This is for an assignment that specifies VS 2005/2008 with C++. I would prefer not to make things more complicated than I need to, but at the same time I like to do things properly where possible.

    Read the article

  • J2ME TextField Exception

    - by Bob
    When I instantiate a textField, I have a number in it that I want to be the default text. The problem is, I can't seem to be able to place that value into the textfield without getting an error. The strange thing about it is that the same TextField is what I use to set the value of the variable containing the number. TextField myTF = new TextField("Number", value, 10, TextField.NUMERIC); When I run this code, I receive an exception stating that value doesn't match the constraints of TextField.NUMERIC. However, when I check the vale of the value of the variable, I get the following output: value = 1234567890 value.length() = 10 The value is set by the same TextField, saved to the phone that I am working on, and when loaded from the phone's settings, throws an exception.

    Read the article

  • Handling PHP exceptions with JQuery

    - by Itamar Bar-Lev
    Hello, I'm using JQuery to call a PHP function that returns a JSON string upon success or throws some exceptions. Currently I'm calling jQuery.parseJSON() on the response and if it fails I assume the response contains an exception string. $.ajax({ type: "POST", url: "something.php", success: function(response){ try { var json = jQuery.parseJSON(response); } catch (e) { alert(response); return -1; } // ... do stuff with json } Can anyone suggest a more elegant way to catch the exception? Many thanks, Itamar

    Read the article

  • BlackBerry - Exception with null message when sending sms using Connector

    - by vikram deshpande
    I used code given but I am getting "IOCancelledException" and "IOException". And IOCancelledException.getMessage() / IOException.getMessage() giving null string, it does not give error message. Please help me understaing reason. class SMSThread extends Thread { Thread myThread; MessageConnection msgConn; String message; String mobilenumber; public SMSThread(String textMsg, String mobileNumber) { message = textMsg; mobilenumber = mobileNumber; } public void run() { try { msgConn = (MessageConnection) Connector.open("sms://+" + mobilenumber); TextMessage text = (TextMessage) msgConn .newMessage(MessageConnection.TEXT_MESSAGE); text.setPayloadText(message); msgConn.send(text); msgConn.close(); } catch (IOCancelledException ioce) { System.out .println("IOCancelledException: " + ioce.getMessage()); } catch (IOException ioe) { System.out.println("IOException: " + ioe.getMessage()); } catch (Exception e) { System.out.println("Exception: " + e); } } }

    Read the article

  • Checked equivalent to IllegalArgumentException?

    - by jv1975oid
    I have a method that takes an enum as a parameter and returns some information dependent on that parameter. However, that enum contains some values which should not be handled, and should raise an error condition. Currently the method throws an IllegalArgumentException but I would like this to be a checked exception to force callers to catch it (and return gracefully, logging an error). Is there something suitable or should I create my own Exception subclass? I'm open to other patterns as well. A reasonable reaction would be that all values of the enum should be handled, but that isn't the case. When a new value is added to the enum, I want to make sure that this method does the right thing - alerting a human is preferable to using some default return value in this case. Thanks for any advice.

    Read the article

  • Linenumber for Exception thrown in runtime-compiled DotNET code

    - by David Rutten
    Not quite the same as this thread, but pretty close. My program allows people to enter some VB or C# code which gets compiled, loaded and executed at runtime. My CompilerParams are: CompilerParameters params = new CompilerParameters(); params.GenerateExecutable = false; params.GenerateInMemory = true; params.IncludeDebugInformation = false; params.TreatWarningsAsErrors = false; params.WarningLevel = 4; When this code throws an exception I'd like to be able to display a message box that helps users debug their code. The exception message is easy, but the line-number is where I got stuck. I suspect that in order to get at the line number, I may need to drastically change the CompilerParameters and perhaps even the way these dlls get stored/loaded. Does anyone know the least steps needed to get this to work?

    Read the article

  • asp.net Background Threads Exception Handling

    - by Chris
    In my 3.5 .net web application I have a background thread that does a lot of work (the application is similar to mint.com in that it does a lot of account aggregation on background threads). I do extensive exception handling within the thread performing the aggregation but there's always the chance an unhandled exception will be thrown and my entire application will die. I've read some articles about this topic but they all seem fairly outdated and none of them implement a standard approach. Is there a standard approach to this nowadays? Is there any nicer way to handle this in ASP.NET 4.0?

    Read the article

  • How to catch specific exception without error number?

    - by CJ7
    I need to catch the following specific exception: System.Data.OleDb.OleDbException was caught ErrorCode=-2147467259 Message="The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again." Source="Microsoft JET Database Engine" I'm not sure what ErrorCode is but it looks unreliable. Can I rely on Message being identical across platforms? Is the only solution to do a text search of Message for words like duplicate and primary key? Note: see my question here for why I need to catch this exception.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >