Search Results

Search found 13797 results on 552 pages for 'structured exception'.

Page 9/552 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Need to determine if ELMAH is logging an unhandled exception or one raised by ErrorSignal.Raise()

    - by Ronnie Overby
    I am using the Elmah Logged event in my Global.asax file to transfer users to a feedback form when an unhandled exception occurs. Sometimes I log other handled exceptions. For example: ErrorSignal.FromCurrentContext().Raise(new System.ApplicationException("Program code not found: " + Student.MostRecentApplication.ProgramCode)); // more code that should execute after logging this exception The problem I am having is that the Logged event gets fired for both unhandled and these handled, raised exceptions. Is there a way to determine, in the Logged event handler, whether the exception was raised via ErrorSignal class or was simply unhandled? Are there other Elmah events that I can take advantage of?

    Read the article

  • Condition checking vs. Exception handling

    - by Aidas Bendoraitis
    When is exception handling more preferable than condition checking? There are many situations where I can choose using one or the other. For example, this is a summing function which uses a custom exception: # module mylibrary class WrongSummand(Exception): pass def sum_(a, b): """ returns the sum of two summands of the same type """ if type(a) != type(b): raise WrongSummand("given arguments are not of the same type") return a + b # module application using mylibrary from mylibrary import sum_, WrongSummand try: print sum_("A", 5) except WrongSummand: print "wrong arguments" And this is the same function, which avoids using exceptions # module mylibrary def sum_(a, b): """ returns the sum of two summands if they are both of the same type """ if type(a) == type(b): return a + b # module application using mylibrary from mylibrary import sum_ c = sum_("A", 5) if c is not None: print c else: print "wrong arguments" I think that using conditions is always more readable and manageable. Or am I wrong? What are the proper cases for defining APIs which raise exceptions and why?

    Read the article

  • ActiveRecord Create (not !) Throwing Exception on Validation

    - by myferalprofessor
    So I'm using ActiveRecord model validations to validate a form in a RESTful application. I have a create action that does: @association = Association.new and the receiving end of the form creates a data hash of attributes from the form parameters to save to the database using: @association = user.associations.create(data) I want to simply render the create action if validation fails. The problem is that the .create (not !) method is throwing an exception in cases where the model validation fails. Example: validates_format_of :url, :with => /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix, :message => "Your url doesn't seem valid." in the model produces: ActiveRecord::RecordInvalid Exception: Validation failed: Url Your url doesn't seem valid. I thought .create! is supposed throw an exception whereas .create is not. Am I missing something here? Ruby 1.8.7 patchlevel 173 & rails 2.3.3

    Read the article

  • Ideal way to set global uncaught exception Handler in Android

    - by Samuh
    I want to set a global uncaught exception handler for all the threads in my Android application. So, in my Application subclass I set an implementation of Thread.UncaughtExceptionHandler as default handler for uncaught exceptions. Thread.setDefaultUncaughtExceptionHandler( new DefaultExceptionHandler(this)); In my implementation, I am trying to display an AlertDialog displaying appropriate exception message. However, this doesn't seem to work. Whenever, an exception is thrown for any thread which goes un-handled, I get the stock, OS-default dialog (Sorry!-Application-has-stopped-unexpectedly dialog). What is the correct and ideal way to set a default handler for uncaught exceptions? Thanks.

    Read the article

  • Common Utility for Exception Searching

    - by Andrew
    I wrote this little helper method to search the exception chain for a particular exception (either equals or super class). However, this seems like a solution to a common problem, so was thinking it must already exist somewhere, possibly in a library I have already imported. So, any ideas on if/where this might exist? boolean exceptionSearch(Exception base, Class<?> search) { Throwable e = base; do { if (search.isAssignableFrom(e.getClass())) { return true; } } while ((e = e.getCause()) != null); return false; }

    Read the article

  • Event is causing an error, but I can't catch the exception

    - by proudgeekdad
    A developer has created a custom control in ASP.NET using VB.NET. The custom control uses a repeater. In certain scenarios, the rpt_ItemDataBound event is encountering a data error. My goal is rather than having the user see the yellow screen of death, give the user a friendlier error explaining exactly what the data error is. I figured I would be able to use a Try/Catch block as shown below throw the exception, however, it appears that the event has nowhere to be thrown to and stops executing at the "End Try" line. Protected Sub rpt_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt1.ItemDataBound, rpt2.ItemDataBound Try ProcessBadData... Catch ex As Exception Throw ex End Try End Sub In VB.NET, I can find where the repeater's DataSource is being set, however, I can not find a DataBind event. Any ideas how I can capture the exception in this ASCX control so I can report it to the user?

    Read the article

  • Exception handling pattern

    - by treefrog
    It is a common pattern I see where the error codes associated with an exception are stored as Static final ints. when the exception is created to be thrown, it is constructed with one of these codes along with an error message. This results in the method that is going to catch it having to look at the code and then decide on a course of action. The alternative seems to be- declare a class for EVERY exception error case Is there a middle ground ? what is the recommended method ?

    Read the article

  • Subterranean IL: Exception handling 2

    - by Simon Cooper
    Control flow in and around exception handlers is tightly controlled, due to the various ways the handler blocks can be executed. To start off with, I'll describe what SEH does when an exception is thrown. Handling exceptions When an exception is thrown, the CLR stops program execution at the throw statement and searches up the call stack looking for an appropriate handler; catch clauses are analyzed, and filter blocks are executed (I'll be looking at filter blocks in a later post). Then, when an appropriate catch or filter handler is found, the stack is unwound to that handler, executing successive finally and fault handlers in their own stack contexts along the way, and program execution continues at the start of the catch handler. Because catch, fault, finally and filter blocks can be executed essentially out of the blue by the SEH mechanism, without any reference to preceding instructions, you can't use arbitary branches in and out of exception handler blocks. Instead, you need to use specific instructions for control flow out of handler blocks: leave, endfinally/endfault, and endfilter. Exception handler control flow try blocks You cannot branch into or out of a try block or its handler using normal control flow instructions. The only way of entering a try block is by either falling through from preceding instructions, or by branching to the first instruction in the block. Once you are inside a try block, you can only leave it by throwing an exception or using the leave <label> instruction to jump to somewhere outside the block and its handler. The leave instructions signals the CLR to execute any finally handlers around the block. Most importantly, you cannot fall out of the block, and you cannot use a ret to return from the containing method (unlike in C#); you have to use leave to branch to a ret elsewhere in the method. As a side effect, leave empties the stack. catch blocks The only way of entering a catch block is if it is run by the SEH. At the start of the block execution, the thrown exception will be the only thing on the stack. The only way of leaving a catch block is to use throw, rethrow, or leave, in a similar way to try blocks. However, one thing you can do is use a leave to branch back to an arbitary place in the handler's try block! In other words, you can do this: .try { // ... newobj instance void [mscorlib]System.Exception::.ctor() throw MidTry: // ... leave.s RestOfMethod } catch [mscorlib]System.Exception { // ... leave.s MidTry } RestOfMethod: // ... As far as I know, this mechanism is not exposed in C# or VB. finally/fault blocks The only way of entering a finally or fault block is via the SEH, either as the result of a leave instruction in the corresponding try block, or as part of handling an exception. The only way to leave a finally or fault block is to use endfinally or endfault (both compile to the same binary representation), which continues execution after the finally/fault block, or, if the block was executed as part of handling an exception, signals that the SEH can continue walking the stack. filter blocks I'll be covering filters in a separate blog posts. They're quite different to the others, and have their own special semantics. Phew! Complicated stuff, but it's important to know if you're writing or outputting exception handlers in IL. Dealing with the C# compiler is probably best saved for the next post.

    Read the article

  • mediaplayer failure exception

    - by Rahulkapil
    I am working on an android application in which i have to play random sounds from my assets folder. there are some images also, when i click on any image from those images a sound must play regarding to that image from assets folder. i managed all but sometime my mediaplayer fails unexpectedly. I am attaching my code also. private Handler threadHandler = new Handler() { public void handleMessage(android.os.Message msg) { /*first*/ try{ InputStream ims1 = getAssets().open("images/" +dataAll_pic_name1); d1 = Drawable.createFromStream(ims1, null); rl1.setVisibility(View.VISIBLE); img1.setImageDrawable(d1); AssetFileDescriptor afd = getAssets().openFd("sounds/" + str_snd1); mp2 = new MediaPlayer(); mp2.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); mp2.prepare(); mp2.start(); mp2.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { /*second*/ try{ InputStream ims2 = getAssets().open("images/" +dataAll_pic_name2); d2 = Drawable.createFromStream(ims2, null); rl2.setVisibility(View.VISIBLE); img2.setImageDrawable(d2); AssetFileDescriptor afd = getAssets().openFd("sounds/" + str_snd2); mp2 = new MediaPlayer(); mp2.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); mp2.prepare(); mp2.start(); mp2.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { /*third*/ try{ InputStream ims3 = getAssets().open("images/" +dataAll_pic_name3); d3 = Drawable.createFromStream(ims3, null); rl3.setVisibility(View.VISIBLE); img3.setImageDrawable(d3); AssetFileDescriptor afd = getAssets().openFd("sounds/" + str_snd3); mp2 = new MediaPlayer(); mp2.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); mp2.prepare(); mp2.start(); mp2.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { /*four*/ try{ InputStream ims4 = getAssets().open("images/" +dataAll_pic_name4); d4 = Drawable.createFromStream(ims4, null); rl4.setVisibility(View.VISIBLE); img4.setImageDrawable(d4); AssetFileDescriptor afd = getAssets().openFd("sounds/" + str_snd4); mp2 = new MediaPlayer(); mp2.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); mp2.prepare(); mp2.start(); mp2.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { startAnimation(); //randomSoundPlay(); timer.schedule( new TimerTask(){ public void run() { System.out.println("Wait, what........................:"); try{ AssetFileDescriptor afd = getAssets().openFd("sounds/" + dataAll_sound_name); mp2 = new MediaPlayer(); mp2.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); mp2.prepare(); mp2.start(); mp2.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { vg1.setClickable(true); vg2.setClickable(true); vg3.setClickable(true); vg4.setClickable(true); btn_spkr.setVisibility(View.VISIBLE); txtImage(); } }); }catch(Exception e){ e.printStackTrace(); } } }, delay_que); } }); }catch(Exception e){ e.printStackTrace(); } } }); }catch(Exception e){ e.printStackTrace(); } } }); }catch(Exception e){ e.printStackTrace(); } } }); }catch(Exception e){ e.printStackTrace(); } } }; in above code random images and sound sets in my activity. now when i click on any image a sound must play but sometimes it fails.. i tried but unable to resolve this issue. help me out. thanks in advance.

    Read the article

  • Suppress unhandled exception dialog?

    - by Nick Brooks
    I'm handling all of my unhanded exception in the code but whenever one happens (not during debugging) I get my error window and as soon as it closes "Unhandled application exception has occurred in your application" window pops up. How do I suppress it? PS : I am not using ASP.NET , I'm using Windows Forms

    Read the article

  • What is this exception ?

    - by Lalit
    I am getting this exception while reading the shapes in excel sheet in c#: on code line of if (worksheet.Shapes.Count >= iCurrentRowIndex) {} Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel._Worksheet'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D8-0000-0000-C000-000000000046}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).

    Read the article

  • ASP.Net MVC Exception Logging combined with Error Handling

    - by Saajid Ismail
    Hi. I am looking for a simple solution to do Exception Logging combined with Error Handling in my ASP.Net MVC 1.0 application. I've read lots of articles, including Questions posted here on StackOverflow, which all provide varying solutions for different situations. I am still unable to come up with a solution that suits my needs. Here are my requirements: To be able to use the [HandleError] attribute (or something equivalent) on my Controller, to handle all exceptions that could be thrown from any of the Actions or Views. This should handle all exceptions that were not handled specifically on any of the Actions (as described in point 2). I would like to be able to specify which View a user must be redirected to in error cases, for all actions in the Controller. I want to be able to specify the [HandleError] attribute (or something equivalent) at the top of specific Actions to catch specific exceptions and redirect users to a View appropriate to the exception. All other exceptions must still be handled by the [HandleError] attribute on the Controller. In both cases above, I want the exceptions to be logged using log4net (or any other logging library). How do I go about achieving the above? I've read about making all my Controllers inherit from a base controller which overrides the OnException method, and wherein I do my logging. However this will mess around with redirecting users to the appropriate Views, or make it messy. I've read about writing my own Filter Action which implements IExceptionFilter to handle this, but this will conflict with the [HandleError] attribute. So far, my thoughts are that the best solution is to write my own attribute that inherits from HandleErrorAttribute. That way I get all the functionality of [HandleError], and can add my own log4net logging. The solution is as follows: public class HandleErrorsAttribute: HandleErrorAttribute { private log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public override void OnException(ExceptionContext filterContext) { if (filterContext.Exception != null) { log.Error("Error in Controller", filterContext.Exception); } base.OnException(filterContext); } } Will the above code work for my requirements? If not, what solution does fulfill my requirements?

    Read the article

  • Oracle enterprise manager java.lang.Exception

    - by folone
    After creating a db using Database Configuration Assistant, I go to Enterprise Manager, log into it, and it tells me, that java.lang.Exception: Exception in sending Request :: null. OracleDBConsole for this db, and iSQLPlus services are started. When I run %ORACLE_HOME%\bin\emctl status dbconsole, it says, EM Daemon is not running. How do I deal with this?

    Read the article

  • Test sql connection without throwing exception

    - by Alexandre Pepin
    To test if i can connect to my database, I execute the following code : using (SqlConnection connection = new SqlConnection(myConnectionString)) { try { connection.Open(); canConnect = true; } catch (SqlException) { } } This works except it throws an exception if the connection failed. Is there any other way to test a Sql connection that doesn't throw an exception ? Edit : To add precision, i'm asking if there is a simple method that does that without having to open the connection and catch exceptions that can occur

    Read the article

  • Java Date exception handling try catch

    - by user69514
    Is there some sort of exception in Java to catch an invalid Date object? I'm trying to use it in the following method, but I don't know what type of exception to look for. Is it a ParseException. public boolean setDate(Date date) { this.date = date; return true; }

    Read the article

  • What is your custom exception hierrarchy?

    - by bonefisher
    My question is: how would you create exception hierarchy in your application? Designing the architecture of an application, from my perspective, we could have three types of exceptions: the built-in (e.g.: InvalidOperationException) custom internal system faults (DB transaction failed on commit, DbTransactionFailedException) custom business exceptions (BusinessRuleViolationException) Class hierarchy: Exception MyAppInternalException DbTransactionFailedException MyServerTimeoutException ... MyAppBusinessRuleViolationException UsernameAlreadyExistsException ... where only MyAppInternalException & MyAppBusinessRuleViolationException would be catched.

    Read the article

  • Java Exceptions

    - by Mandar
    This may sound awkward ... But I didn't understand it. Why do we have compile-time error and not compile-time exception in java ? I mean to say that we never say compile-time exception. We tend to say it as compile-time error. Is there any specific reason for the same ?? Any suggestions are welcomed.... Thanks !

    Read the article

  • Problem with combination boost::exception and boost::variant

    - by Rick
    Hello all, I have strange problem with two-level variant struct when boost::exception is included. I have following code snippet: #include <boost/variant.hpp> #include <boost/exception/all.hpp> typedef boost::variant< int > StoredValue; typedef boost::variant< StoredValue > ExpressionItem; inline std::ostream& operator << ( std::ostream & os, const StoredValue& stvalue ) { return os;} inline std::ostream& operator << ( std::ostream & os, const ExpressionItem& stvalue ) { return os; } When I try to compile it, I have following error: boost/exception/detail/is_output_streamable.hpp(45): error C2593: 'operator <<' is ambiguous test.cpp(11): could be 'std::ostream &operator <<(std::ostream &,const ExpressionItem &)' [found using argument-dependent lookup] test.cpp(8): or 'std::ostream &operator <<(std::ostream &,const StoredValue &)' [found using argument-dependent lookup] 1> while trying to match the argument list '(std::basic_ostream<_Elem,_Traits>, const boost::error_info<Tag,T>)' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char> 1> ] 1> and 1> [ 1> Tag=boost::tag_original_exception_type, 1> T=const type_info * 1> ] Code snippet is simplified as much as possible, in the real code are structures much more complicated and each variant has five sub-types. When i remove #include and try following test snippet, program is compiled correctly: void TestVariant() { ExpressionItem test; std::stringstream str; str << test; } Could someone please advise me how to define operators << in order to function even when using boost::Exception ? Thanks and regards Rick

    Read the article

  • Default .NET exception handler

    - by ajs410
    So the other day my C# application crashed. Usually, with a .NET application, if you have an unhandled exception you get a nice error message with a stack trace. However, this time, I got a different dialog that just told me there was an error and offered to attach a Debugger, but there was no stack trace in the dialog and the machine it was running on had no debugger installed. What gives? Why don't I see the default .NET exception handler?

    Read the article

  • Unresponsive Clojure REPL after exception

    - by Hendekagon
    If I start a REPL and then do something that throws an exception like (use 'non-existent-thing) ** then after that the REPL ceases to evaluate anything I enter. Is there a special key I can press to make it turn round, face me, uncross its arms and listen once more ? Or must I ctrl-d, restart, type everything up to where I was and get it right this time ? ** which results in: Exception in thread "Thread-1" java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate non_existent_thing__init.class or non_existent_thing.clj on classpath: (NO_SOURCE_FILE:0)

    Read the article

  • How to catch an exception and email information about it in liferay portlet

    - by heikkim
    I have a custom portlet made for liferay and sometimes it throws an exception. Why it throws exceptions is irrelevant. How to catch exceptions thrown by portlet handler methods in order to email information about them? I know I could do try catching on every handler method but it would be a much more elegant and cleaner solution to catch the exception on a higher level and just email some information about the error. I'm using Spring Portlet MVC, so i got all spring-related niceties at hand.

    Read the article

  • Check if Database raises a particular exception

    - by mcabral
    using Nhibernate; I'm trying to insert several values a on table which has an unique index on some columns. I'd like to know if a particular insert raises an exception for having violated the unique constraint. So, which particular exception type should i catch? I only want to catch this particular one and let all others go up. Thanks a lot!

    Read the article

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