Search Results

Search found 13112 results on 525 pages for 'exception duck'.

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

  • 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

  • How do I display exception errors thrown by Zend framework

    - by Ali
    Hi guys I'm working with Zend framework and just hate the fact that I seem to encounter hundreds of exception errors like if I try to reference a non existant property of an object my application just dies and crashes. However I have no idea where to see these errors or how to be able to display them on screen. I've set display errors to true and error reporting to E_ALL but when an error is thrown all I see is a blank page rendered only until a bit before where the error apparently occurred or the exception was thrown. Help please my debugging hours are dragging

    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

  • 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

  • Sending an email when an Exception is Thrown

    - by hariubc
    Hi: I have written a java class where if a method throws an exception, an email is sent, via java mail, with a report to the administrators. It works - my question is w.r.t elegance - to catch the exception thrown by the main method, the sendEmail() method resides in the catch block of the main method. The sendEmail() method has its own try-catch block. In effect - it looks like below - is there a more beautiful way of writing this? try { foo; } catch { try{ sendEmail(); } catch { log(e.message); } }

    Read the article

  • JDBC ResultSet.getString Before/After Start/End of ResultSet Exception

    - by Geowil
    I have done a lot of searching about this topic through Google but I have yet to find someone using getString() in the way that I am using it so I have not been able to fix this issue in the normal ways that are suggested. What I am trying to do is to obtain all of the information from the database and then use it to populate a table model within the program. I do so by obtaining the data with getString and place it into a String[] object: try { while (rSet.next()) { String row[] = {rSet.getString("DonorName"),rSet.getString("DonorCharity"),((String)rSet.getString("DonationAmount"))}; model.addRow(row); } } However I am always getting a dialog error message stating those error messages in the title: Exception: Before start of result set Exception: After end of result set The data is still added and everything works correctly but it is just annoying to have to dismiss those message windows. Does anyone have some suggestions?

    Read the article

  • The Java interface doesn't declare any exception. How to manage checked exception of the implementat

    - by Frór
    Let's say I have the following Java interface that I may not modify: public interface MyInterface { public void doSomething(); } And now the class implementing it is like this: class MyImplementation implements MyInterface { public void doSomething() { try { // read file } catch (IOException e) { // what to do? } } } I can't recover from not reading the file. A subclass of RuntimeException can clearly help me, but I'm not sure if it's the right thing to do: the problem is that that exception would then not be documented in the class and a user of the class would possibly get that exception an know nothing about solving this. What can I do?

    Read the article

  • JsonStore.insert() causes exception in extjs

    - by kalan
    I have an EditorGridPanel with toolbar button to add new records. Everything works fine except one scenario. When I try to insert a record which already exists in database, server sends back: {"success":false,"message":"already exists","data":{}} but grid creates a new row marked with red triangle. If after that I try to insert a new record (even if it doesn't exist in database), everything works fine on the server side, but i get an 'uncaught exception' in firebug. It says: 'uncaught exception: Ext.data.DataReader: #realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.' why is that?

    Read the article

  • Python continue from the point where exception was thrown

    - by James Lin
    Hi is there a way to continue from the point where exception was thrown? eg I have the following psudo code unique code 1 unique code 2 unique code 3 if I want to ignore the exceptions of any of the unique code statements I will have to do it like this: try: #unique code 1 except: pass try: #unique code 2 except: pass try: #unique code 3 except: pass but this isn't elegant to me, and for the life of me I can't remember how I resolved this kind of problem last time... what I want to have is something like try: unique code 1 unique code 2 unique code 3 except: continue from last exception raised

    Read the article

  • C++ catch constructor exception

    - by aaa
    hi. I do not seem to understand how to catch constructor exception. Here is relevant code: struct Thread { rysq::cuda::Fock fock_; template<class iterator> Thread(const rysq::cuda::Centers &centers, const iterator (&blocks)[4]) : fock_() { if (!fock_) throw; } }; Thread *ct; try { ct = new Thread(centers_, blocks); } catch(...) { return false; } // catch never happens, So catch statement do not execute and I get unhandled exception. What did I do wrong? this is straight C++ using g++.

    Read the article

  • Exception handling in WebForms

    - by user999379
    I have a webform with a formview <asp:FormView ID="formViewBrouwers" runat="server" AllowPaging="True" DataKeyNames="BrouwerNr" DataSourceID="brouwerDataSource" onitemupdated="formViewBrouwers_ItemUpdated" onitemupdating="formViewBrouwers_ItemUpdating" oniteminserted="formViewBrouwers_ItemInserted" oniteminserting="formViewBrouwers_ItemInserting"> <EditItemTemplate> BrouwerNr: <asp:Label ID="BrouwerNrLabel1" runat="server" Text='<%# Eval("BrouwerNr") %>' /> <br /> BrNaam: <asp:TextBox ID="BrNaamTextBox" runat="server" Text='<%# Bind("BrNaam") %>' /> <br /> Adres: <asp:TextBox ID="AdresTextBox" runat="server" Text='<%# Bind("Adres") %>' /> <br /> Postcode: <asp:TextBox ID="PostcodeTextBox" runat="server" Text='<%# Bind("Postcode") %>' /> <br /> Gemeente: <asp:TextBox ID="GemeenteTextBox" runat="server" Text='<%# Bind("Gemeente") %>' /> <br /> Omzet: <asp:TextBox ID="OmzetTextBox" runat="server" Text='<%# Bind("Omzet") %>' /> <br /> Status: <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' /> <br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> <InsertItemTemplate> BrNaam: <asp:TextBox ID="BrNaamTextBox" runat="server" Text='<%# Bind("BrNaam") %>' /> <br /> Adres: <asp:TextBox ID="AdresTextBox" runat="server" Text='<%# Bind("Adres") %>' /> <br /> Postcode: <asp:TextBox ID="PostcodeTextBox" runat="server" Text='<%# Bind("Postcode") %>' /> <br /> Gemeente: <asp:TextBox ID="GemeenteTextBox" runat="server" Text='<%# Bind("Gemeente") %>' /> <br /> Omzet: <asp:TextBox ID="OmzetTextBox" runat="server" Text='<%# Bind("Omzet") %>' /> <br /> Status: <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' /> <br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /> &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </InsertItemTemplate> <ItemTemplate> BrouwerNr: <asp:Label ID="BrouwerNrLabel" runat="server" Text='<%# Eval("BrouwerNr") %>' /> <br /> BrNaam: <asp:Label ID="BrNaamLabel" runat="server" Text='<%# Bind("BrNaam") %>' /> <br /> Adres: <asp:Label ID="AdresLabel" runat="server" Text='<%# Bind("Adres") %>' /> <br /> Postcode: <asp:Label ID="PostcodeLabel" runat="server" Text='<%# Bind("Postcode") %>' /> <br /> Gemeente: <asp:Label ID="GemeenteLabel" runat="server" Text='<%# Bind("Gemeente") %>' /> <br /> Omzet: <asp:Label ID="OmzetLabel" runat="server" Text='<%# Bind("Omzet") %>' /> <br /> Status: <asp:Label ID="StatusLabel" runat="server" Text='<%# Bind("Status") %>' /> <br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" /> &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" /> &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" /> </ItemTemplate> <PagerSettings Mode="NextPreviousFirstLast" /> </asp:FormView> In my property Postcode I check the value like this: private Int16 postcodeValue; public Int16 Postcode { get { return postcodeValue; } set { if (value < 1000 || value > 9999) { throw new Exception("Postcode moet tussen 1000 en 9999 liggen"); } else { postcodeValue = value; } } } How can I handle the exception I threw? If there is an exception I want a label to appear with the following exception?

    Read the article

  • c++: strange syntax in what() method of std::exception

    - by Patrick Oscity
    When i am inheriting from std::exception in order to define my own exception type, i need to override the what() method, which has the following signature: virtual const char* what() const throw(); This definitely looks strange to me, like if there were two method names in the signature. Is this some very specific syntax, like with pure virtual methods, e.g.: virtual int method() const = 0; or is this a feature, that could somehow be used in another context, too? And if so, for what could it be used?

    Read the article

  • Browser not handling exception from AJAX panel, ASP.NET c#

    - by Grant
    Hi, i am having trouble catching errors in an AJAX panel. Even when i throw an exception in the c# code behind the front end completely ignores it. Here is the code i have setup, can anyone see why? I ideally want to show a js alert window on error. Code Behind: protected void btnX_Click(object sender, EventArgs e) { throw new ApplicationException("test"); } protected void ScriptManager_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e) { ScriptManager.AsyncPostBackErrorMessage = e.Exception.Message; } Markup: <script type="text/javascript" language="javascript"> Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function EndRequestHandler(sender, e) { window.alert(e.get_error().name); } </script> <asp:ScriptManager ID="ScriptManager" runat="server" AllowCustomErrorsRedirect="true" OnAsyncPostBackError="ScriptManager_AsyncPostBackError" />

    Read the article

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