Search Results

Search found 2244 results on 90 pages for 'exceptions'.

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

  • Method chaining and exceptions in C#

    - by devoured elysium
    If I have a method chain like the following: var abc = new ABC(); abc.method1() .method2() .methodThrowsException() .method3() ; assuming I've defined method1(), method2() and method3() as public ABC method1() { return this; } and methodThrowsException() as public ABC method3() { throw new ArgumentException(); } When running the code, is it possible to know which specific line of code has thrown the Exception, or will it just consider all the method chaining as just one line? I've done a simple test and it seems it considers them all as just one line but Method Chaining says Putting methods on separate lines also makes debugging easier as error messages and debugger control is usually on a line by line basis. Am I missing something, or does that just not apply to C#? Thanks

    Read the article

  • Java & Tomcat: SQL JDBC/JNDI Exceptions

    - by user267581
    I am deploying a webapp from eclipse to tomcat. I am having an issue with my application and JNDI lookups. When the app tries to load the JNDI resource I am this stacktrace: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect] at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101) at javax.naming.InitialContext.lookup(InitialContext.java:396) at org.objectweb.carol.jndi.spi.AbsContext.lookup(AbsContext.java:134) at org.objectweb.carol.jndi.spi.AbsContext.lookup(AbsContext.java:144) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.objectweb.carol.jndi.spi.MultiContext.lookup(MultiContext.java:118) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.theriabook.daoflex.JDBCConnection.getDataSource(JDBCConnection.java:61) at com.theriabook.daoflex.JDBCConnection.getConnection(JDBCConnection.java:73) at com.aramark.data.UsersDAO.doLogin(UsersDAO.java:751) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:406) at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183) at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1417) at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:878) at com.farata.remoting.CustomAMFEndpoint.serviceMessage(CustomAMFEndpoint.java:23) at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121) at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158) at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:49) at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67) at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146) at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:274) at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:377) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.cti.compiler.env.web.CompilerInvocationInterceptor.doFilter(CompilerInvocationInterceptor.java:25) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322) at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97) ... 41 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:525) at java.net.Socket.connect(Socket.java:475) at java.net.Socket.<init>(Socket.java:372) at java.net.Socket.<init>(Socket.java:186) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595) I am really stumped at this error. I am using a WinXP running on a Virtual Machine (VMWare) from a MAC. Any ideas? I have uninstalled/reinstalled tomcat multiple times.

    Read the article

  • Eclipse - Handling Java Exceptions like in NetBeans

    - by Xorty
    I recently moved from NetBeans to Eclipse and I very much miss one great feature - whenever I use method which throws some kind of exception, NetBeans alerted me and I needed to add try-catch and NetBeans automatically generated exception type for me. Is there something similiar for Eclipse? f.e. : Integer.parseInt(new String("foo")); NetBeans alerts I need to catch NumberFormatException. Eclipse doesn't alert me at all I am using Eclipse Java EE IDE for Web Developers, 3.5 - Galileo

    Read the article

  • Pear MDB2 class and raiserror exceptions in MSSQL

    - by drholzmichl
    Hi, in MSSQL it's possible to raise an error with raiserror(). I want to use a severity, which doesn't interrupt the connection. This error is raised in a stored procedure. In SQL Management Studio all is fine and I get my error code when executing this SP. But when trying to execute this SP via MDB2 in PHP5 this doesn't work. All I get is an empty array. MDB2 object is created via (including needed options): $db =& MDB2::connect($dsn); $db->setFetchMode(MDB2_FETCHMODE_ASSOC); $db->setOption('portability',MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL); The following works (I get a PEAR error): $db->query("RAISERROR('test',11,0);"); But when calling a stored procedure which raises this error via $db->query("EXEC sp_raise_error"); there is not output. What's wrong?

    Read the article

  • php 5.3.2 not throwing exceptions

    - by tipu
    I'm attempting to throw an exception using php 5.3.2 and it is giving me the following error: Parse error: syntax error, unexpected T_THROW I am attempting to throw an exception the following way: throw new Exception('Property ' . $name . ' doesn\'t exist in class Index', ''); Edit: I also tried throw new Exception('Property ' . $name . ' doesn\'t exist in class Index'); it didn't change the error I was getting. The complete method: public function __get($name) { if(property_exists($this, $name) throw new Exception('Property ' . $name . ' doesn\'t exist in class Index'); return $this->$name; }

    Read the article

  • Visual Studio 2010 failed tests throw exceptions

    - by Dave Hanson
    In VisualStudio2010 Ultimate RC I cannot figure out how to suppress {"CollectionAssert.AreEqual failed. (Element at index 0 do not match.)"} from Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException If i Ctrl+Alt+E I get the exception dialog; however that exception doesn't seem to be in there to be suppressed. Does anyone else have any experience with this? I don't remember having to suppress these Assert fails in studio 2008 when running unit tests. My tests would fail and I could just click on the TestResults to see which tests failed instead of fighting through these dialogs. For now I guess I'll just run my tests through the command window.

    Read the article

  • Serializing Exceptions WCF + Silverlight

    - by Bram
    I have a WCF service I use to submit bugs for my project. Snippet of the data class: Private _exception As Exception <DataMember()> _ Public Property Exception As Exception Get Return _exception End Get Set(ByVal value As Exception) _exception = value End Set End Property I have a Silverlight app that uses the WCF service to send any bugs home if and when they occur. This is the error I'm testing with: Dim i As Integer = 5 i = i / 0 The problem is SL is banging on with this message: System.ServiceModel.CommunicationException was unhandled by user code Message=There was an error while trying to serialize parameter :bug. The InnerException message was 'Type 'System.OverflowException' with data contract name 'OverflowException:http://schemas.datacontract.org/2004/07/System' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details. Is there some trick to get a generic .NET Exception (any InnerException) to serialize properly? I'm not doing anything funky with the exception - it's just a plain 'ol exception Thanks for any help.

    Read the article

  • Problems with "global" exception handlers for unhandled exceptions in multithreaded WPF

    - by JustABill
    I have a program that, among other things, needs to be able to refresh the contents of a directory when the user tells it to. The actual task doesn't really matter, but this is the simplest way of causing this problem to occur that I know of. If I tell it to open a directory that doesn't exist, I get the "unhandled exception" dialog in VS with a stack trace of, from outer to inner: [External code] Textbox PreviewKeyUp event [External code] ClassA's path property being set ClassA's internal path update function being called A call to the INotifyPropertyChanged event [External code] A call to the getter for ClassB's list of children A call to ClassB's internal directory list function And then it fails inside this internal function. I have the following in my App.xaml.cs: private void Application_Startup(object sender, StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.Current.Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException); } But neither of their exception handlers are being called. If I run this program from outside VS, I don't get notified of an exception at all, it just breaks because of the invalid input. And yes, the Application_Startup event is being called. How can I properly "trap" this exception so I can provide a friendly error message and kill the program?

    Read the article

  • OpenGL suppresses exceptions in MFC dialog-based application

    - by Mikhail
    Hello. I have an MFC-driven dialog-based application created with MSVS2005. Here is my problem step by step. I have button on my dialog and corresponding click-handler with code like this: int* i = 0; *i = 3; I'm running debug version of program and when I click on the button, Visual Studio catches focus and alerts "Access violation writing location" exception, program cannot recover from the error and all I can do is to stop debugging. And this is the right behavior. Now I add some OpenGL initialization code in the OnInitDialog() method: HDC DC = GetDC(GetSafeHwnd()); static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 24, // 24-bit color depth 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored 32, // 32-bit z-buffer 0, // no stencil buffer 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; int pixelformat = ChoosePixelFormat(DC, &pfd); SetPixelFormat(DC, pixelformat, &pfd); HGLRC hrc = wglCreateContext(DC); ASSERT(hrc != NULL); wglMakeCurrent(DC, hrc); Of course this is not exactly what I do, it is the simplified version of my code. Well now the strange things begin to happen: all initialization is fine, there are no errors in OnInitDialog(), but when I click the button... no exception is thrown. Nothing happens. At all. If I set a break-point at the *i = 3; and press F11 on it, the handler-function halts immediately and focus is returned to the application, which continue to work well. I can click button again and the same thing will happen. It seems like someone had handled occurred exception of access violation and silently returned execution into main application message-receiving cycle. If I comment the line wglMakeCurrent(DC, hrc);, all works fine as before, exception is thrown and Visual Studio catches it and shows window with error message and program must be terminated afterwards. I experience this problem under Windows 7 64-bit, NVIDIA GeForce 8800 with latest drivers (of 11.01.2010) available at website installed. My colleague has Windows Vista 32-bit and has no such problem - exception is thrown and application crashes in both cases. Well, hope good guys will help me :) PS The problem originally where posted under this topic.

    Read the article

  • Dynamic Linq Library Guid exceptions

    - by Adan
    I am having a problem with the Dynamic Linq Library. I get a the following error "ParserException was unhandled by user code ')" or ','". I have a Dicitionary and I want to create a query based on this dictionary. So I loop through my dictionary and append to a string builder "PersonId = (GUID FROM DICTIONARY). I think the problem is were I append to PersonId for some reason I can't seem to convert my string guid to a Guid so the dynamic library don't crash. I have tried this to convert my string guid to a guid, but no luck. query.Append("(PersonId = Guid(" + person.Key + ")"); query.Append("(PersonId = " + person.Key + ")"); I am using VS 2010 RTM and RIA Services as well as the Entity Framework 4. //This is the loop I use foreach (KeyValuePair<Guid, PersonDetails> person in personsDetails) { if ((person.Value as PersonDetails).IsExchangeChecked) { query.Append("(PersonId = Guid.Parse(" + person.Key + ")"); } } //Domain service call var query = this.ObjectContext.Persons.Where(DynamicExpression.ParseLambda<Person, bool>(persons)); Please help, and if you know of a better way of doing this I am open to suggestions.

    Read the article

  • Avoiding exceptions when uploading files in laravel

    - by occam98
    I've got a file upload field (attachment1) in a form that may or may not have a file uploaded in it when I process the form in laravel. When I'm trying to process the page, this line generates an exception: Input::upload('attachment1',path('storage').'attachments/'.$name); Here is the text of the exception: Message: Call to a member function move() on a non-object it seems that I need to check in advance to see if 'attachment1' has a file, and I found that the function Input::has_file('attachment1') is supposed to tell me whether or not 'attachment1' has a file, but even when I submit an empty form, it returns true. Also, from reading documentation, it seems that Input::upload is supposed to just return false when trying to upload a non-existant file, so why does it produce this exception instead, and how can I fix it?

    Read the article

  • Spring - disable bind exceptions (for a particular property)

    - by Walter White
    Hi all, In a web application I'm working on using Spring 2.5.6.SEC01, I essentially have an Integer field that takes a number to determine which page to scroll to. The requirements changed, and we no longer want to display an error message, but simply ignore the user's input if they enter an invalid number, say "adfadf". I was reading that you can do that via: TypeMismatch.property=Some New Error Message However, after having tried that, we are still getting the original error message: java.lang.Integer.TypeMismatch=... I only want to disable this message for that given property. How can I do that? I still want binding to occur automatically, I just don't want to hear about it now. Walter

    Read the article

  • Use continue or Checked Exceptions when checking and processing objects

    - by Johan Pelgrim
    I'm processing, let's say a list of "Document" objects. Before I record the processing of the document successful I first want to check a couple of things. Let's say, the file referring to the document should be present and something in the document should be present. Just two simple checks for the example but think about 8 more checks before I have successfully processed my document. What would have your preference? for (Document document : List<Document> documents) { if (!fileIsPresent(document)) { doSomethingWithThisResult("File is not present"); continue; } if (!isSomethingInTheDocumentPresent(document)) { doSomethingWithThisResult("Something is not in the document"); continue; } doSomethingWithTheSucces(); } Or for (Document document : List<Document> documents) { try { fileIsPresent(document); isSomethingInTheDocumentPresent(document); doSomethingWithTheSucces(); } catch (ProcessingException e) { doSomethingWithTheExceptionalCase(e.getMessage()); } } public boolean fileIsPresent(Document document) throws ProcessingException { ... throw new ProcessingException("File is not present"); } public boolean isSomethingInTheDocumentPresent(Document document) throws ProcessingException { ... throw new ProcessingException("Something is not in the document"); } What is more readable. What is best? Is there even a better approach of doing this (maybe using a design pattern of some sort)? As far as readability goes my preference currently is the Exception variant... What is yours?

    Read the article

  • ClassLoader exceptions being memoized

    - by Jim
    Hello, I am writing a classloader for a long-running server instance. If a user has not yet uploaded a class definition, I through a ClassNotFoundException; seems reasonable. The problem is this: There are three classes (C1, C2, and C3). C1 depends on C2, C2 depends on C3. C1 and C2 are resolvable, C3 isn't (yet). C1 is loaded. C1 subsequently performs an action that requires C2, so C2 is loaded. C2 subsequently performs an action that requires C3, so the classloader attempts to load C3, but can't resolve it, and an exception is thrown. Now C3 is added to the classpath, and the process is restarted (starting from the originally-loaded C1). The issue is, C2 seems to remember that C3 couldn't be loaded, and doesn't bother asking the classloader to find the class... it just re-throws the memoized exception. Clearly I can't reload C1 or C2 because other classes may have linked to them (as C1 has already linked to C2). I tried throwing different types of errors, hoping the class might not memoize them. Unfortunately, no such luck. Is there a way to prevent the loaded class from binding to the exception? That is, I want the classloader to be allowed to keep trying if it didn't succeed the first time. Thanks!

    Read the article

  • Handling exceptions raised in observers

    - by sparky
    I have a Rails (2.3.5) application where there are many groups, and each Group has_many People. I have a Group edit form where users can create new people. When a new person is created, they are sent an email (the email address is user entered on the form). This is accomplished with an observer on the Person model. The problem comes when ActionMailer throws an exception - for example if the domain does not exist. Clearly that cannot be weeded out with a validation. There would seem to be 2 ways to deal with this: A begin...rescue...end block in the observer around the mailer. The problem with this is that the only way to pass any feedback to the user would be to set a global variable - as the observer is out of the MVC flow, I can't even set a flash[:error] there. A rescue_from in the Groups controller. This works fine, but has 2 problems. Firstly, there is no way to know which person threw the exception (all I can get is the 503 exception, no way to know which person caused the problem). This would be useful information to be able to pass back to the user - at the moment, there is no way for me to let them know which email address is the problem - at the moment, I just have to chuck the lot back at them, and issue an unhelpful message saying that one of them is not correct. Secondly (and to a certain extent this make the first point moot) it seems that it is necessary to call a render in the rescue_from, or it dies with a rather bizarre "can't convert Array into String" error from webbrick, with no stack trace & nothing in the log. Thus, I have to throw it back to the user when I come across the first error and have to stop processing the rest of the emails. Neither of the solutions are optimal. It would seem that the only way to get Rails to do what I want is option 1, and loathsome global variables. This would also rely on Rails being single threaded. Can anyone suggest a better solution to this problem?

    Read the article

  • How can I handle maxRequestLength exceptions elegantly?

    - by JMP
    In my ASP.NET MVC (v2 if it matters) app, I have a page that allows the user to upload a file. I've configured the maxRequestLength for my app to allow files up to 25MB. As a test, I send it a 500MB file which throws the exception: Maximum request length exceeded. (I only know this because ELMAH catches the error and logs it.) In my web.config, I've set customErrors mode="On" with a defaultRedirect, but the user isn't redirected at all, they don't even get a yellow-screen-of-death. In Chrome, for example, you'll see the error: Error 101 (net::ERR_CONNECTION_RESET): Unknown error. Is it possible to provide a more elegant user experience for this situation?

    Read the article

  • GAE how to see production exceptions?

    - by bach
    Hi, I'm getting an error on the production env but not on the local one. Is there a way to see the exception that is probably being thrown from production? In tomcat - the user will be able the see the exception as the servlet returns its output

    Read the article

  • Pear MDB2 class and raiserror exceptions in SQL Server

    - by drholzmichl
    Hi, in SQL Server it's possible to raise an error with raiserror(). I want to use a severity, which doesn't interrupt the connection. This error is raised in a stored procedure. In SQL Management Studio all is fine and I get my error code when executing this SP. But when trying to execute this SP via MDB2 in PHP5 this doesn't work. All I get is an empty array. MDB2 object is created via (including needed options): $db =& MDB2::connect($dsn); $db->setFetchMode(MDB2_FETCHMODE_ASSOC); $db->setOption('portability',MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL); The following works (I get a PEAR error): $db->query("RAISERROR('test',11,0);"); But when calling a stored procedure which raises this error via $db->query("EXEC sp_raise_error"); there is not output. What's wrong?

    Read the article

  • PowerShell 2.0 and how to handle exceptions ?

    - by Primoz
    Why I get error message printed on the console when running these two simple samples ? I want that I get "Error testing :)" printed on the console insted of: Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) At line:3 char:15 + Get-WmiObject <<<< -ComputerName possibly.nonexisting.domain.com -Credential (Get-Credential) -Class Win32_logicaldisk + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand or Attempted to divide by zero. At line:3 char:13 + $i = 1/ <<<< 0 + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : RuntimeException First example: try { $i = 1/0 Write-Host $i } catch [Exception] { Write-Host "Error testing :)" } Second example: try { Get-WmiObject -ComputerName possibly.nonexisting.domain.com -Credential (Get-Credential) -Class Win32_logicaldisk } catch [Exception] { Write-Host "Error testing :)" } Thank you very much!

    Read the article

  • GAE transaction exceptions

    - by bach
    Hi, In this example IS the exception being thrown if ANY of the Table elements are being changed by another client OR only if the element that we changed has been changed by another client? Just to verify - the exception is thrown from the commit() isn't it? PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.currentTransaction().begin(); List<Row> Table = (List<Row>) pm.newQuery(query).execute(); Table.get(0).setReserved(true); // <----- we change only this element pm.currentTransaction().commit(); } catch (JDOCanRetryException ex) { pm.currentTransaction().rollback() // <----- if Table.get(1) was changed by another client do we get to this point??? }

    Read the article

  • Catching specific vs. generic exceptions in c#

    - by Scott Vercuski
    This question comes from a code analysis run against an object I've created. The analysis says that I should catch a more specific exception type than just the basic Exception. Do you find yourself using just catching the generic Exception or attempting to catch a specific Exception and defaulting to a generic Exception using multiple catch blocks? One of the code chunks in question is below: internal static bool ClearFlags(string connectionString, Guid ID) { bool returnValue = false; SqlConnection dbEngine = new SqlConnection(connectionString); SqlCommand dbCmd = new SqlCommand("ClearFlags", dbEngine); SqlDataAdapter dataAdapter = new SqlDataAdapter(dbCmd); dbCmd.CommandType = CommandType.StoredProcedure; try { dbCmd.Parameters.AddWithValue("@ID", ID.ToString()); dbEngine.Open(); dbCmd.ExecuteNonQuery(); dbEngine.Close(); returnValue = true; } catch (Exception ex) { ErrorHandler(ex); } return returnValue; } Thank you for your advice EDIT: Here is the warning from the code analysis Warning 351 CA1031 : Microsoft.Design : Modify 'ClearFlags(string, Guid)' to catch a more specific exception than 'Exception' or rethrow the exception

    Read the article

  • Rails: common approach for handling exceptions in restful actions on objects that have been destroye

    - by Greg
    It is very common in Rails for an objects_controller controller to have RESTful edit and destroy actions like so: def edit @object = Object.find(params[:id]) end def destroy @object = Object.find(params[:id]) @object.destroy redirect_to :back end With an associated view that provides edit and destroy links like so: <%= link_to "Edit the Object", edit_object_path(object) %> <%= link_to "Delete", object, :confirm => 'Are you sure?', :method => :delete %> And it is easy to blow this up. If I open two browser windows, A and B, destroy an object with the "Delete" link in browser A and then press the "Edit" link in browser B, the find() in the edit action throws an exception. Obviously there are several ways to deal with this in the edit action: catch the exception and recover gracefully use @object = find(:first, "conditions... etc. and test the @object before going further But seeing as this is such a common pattern, I would love to know how other folks deal with this situation.

    Read the article

  • How to catch this type of exceptions ?

    - by Lukas Šalkauskas
    I'm starting getting tired of this exception. Can't handle it, even so I'm using this: AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Still no success, Can anyone explain me, how I should handle it in a nice way. Or how to detect that it have fired this message and close the application, because I'm starting it automatically everytime it closes.

    Read the article

  • Why does SQL Server keep throwing exceptions?

    - by Augusto Càzares
    I have my project in .NET that uses a database in SQL Server. I'm using Linq-to-SQL, sometimes when the project throws me an exception (Constraint) in a part of the project this same error keeps showing in other part of the project when I do another thing with the database. Like when I do an insertion and I had before an exception on delete the insertion throws me the delete exception, and it remains this way until I close and open again the project. My major problem is when this happen in my online project, this error in my project causes me problems in the project I'm testing online (I use the same database). I don't know if this exception is on the memory or something but its have been causing me a lot of headaches.

    Read the article

  • Where do I handle asynchronous exceptions?

    - by Jurily
    Consider the following code: class Foo { // boring parts omitted private TcpClient socket; public void Connect(){ socket.BeginConnect(Host, Port, new AsyncCallback(cbConnect), quux); } private void cbConnect(IAsyncResult result){ // blah } } If socket throws an exception after BeginConnect returns and before cbConnect gets called, where does it pop up? Is it even allowed to throw in the background?

    Read the article

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