Search Results

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

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

  • Java w/ SQL Server Express 2008 - Index out of range exception

    - by BS_C3
    Hi! I created a stored procedure in a sql express 2008 and I'm getting the following error when calling the procedure from a Java method: Index 36 is out of range. com.microsoft.sqlserver.jdbc.SQLServerException:Index 36 is out of range. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:698) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setValue(SQLServerPreparedStatement.java:707) at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.setString(SQLServerCallableStatement.java:1504) at fr.alti.ccm.middleware.Reporting.initReporting(Reporting.java:227) at fr.alti.ccm.middleware.Reporting.main(Reporting.java:396) I cannot figure out where it is coming from... _< Any help would be appreciated. Regards, BS_C3 Here's some source code: public ArrayList<ReportingTableMapping> initReporting( String division, String shop, String startDate, String endDate) { ArrayList<ReportingTableMapping> rTable = new ArrayList<ReportingTableMapping>(); ManagerDB db = new ManagerDB(); CallableStatement callStmt = null; ResultSet rs = null; try { callStmt = db.getConnexion().prepareCall("{call getInfoReporting(?,...,?)}"); callStmt.setString("CODE_DIVISION", division); . . . callStmt.setString("cancelled", " "); rs = callStmt.executeQuery(); while (rs.next()) { ReportingTableMapping rtm = new ReportingTableMapping( rs.getString("werks"), ... ); rTable.add(rtm); } rs.close(); callStmt.close(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } finally { if (rs != null) try { rs.close(); } catch (Exception e) { } if (callStmt != null) try { callStmt.close(); } catch (Exception e) { } if (db.getConnexion() != null) try { db.getConnexion().close(); } catch (Exception e) { } } return rTable; }

    Read the article

  • VB .NET error handling, pass error to caller

    - by user1375452
    this is my very first project on vb.net and i am now struggling to migrate a vba working add in to a vb.net COM Add-in. I think i'm sort of getting the hang, but error handling has me stymied. This is a test i've been using to understand the try-catch and how to pass exception to caller Public Sub test() Dim ActWkSh As Excel.Worksheet Dim ActRng As Excel.Range Dim ActCll As Excel.Range Dim sVar01 As String Dim iVar01 As Integer Dim sVar02 As String Dim iVar02 As Integer Dim objVar01 As Object ActWkSh = Me.Application.ActiveSheet ActRng = Me.Application.Selection ActCll = Me.Application.ActiveCell iVar01 = iVar02 = 1 sVar01 = CStr(ActCll.Value) sVar02 = CStr(ActCll.Offset(1, 0).Value) Try objVar01 = GetValuesV(sVar01, sVar02) 'DO SOMETHING HERE Catch ex As Exception MsgBox("ERRORE: " + ex.Message) 'LOG ERROR SOMEWHERE Finally MsgBox("DONE!") End Try End Sub Private Function GetValuesV(ByVal QryStr As Object, ByVal qryConn As String) As Object Dim cnn As Object Dim rs As Object Try cnn = CreateObject("ADODB.Connection") cnn.Open(qryConn) rs = CreateObject("ADODB.recordset") rs = cnn.Execute(QryStr) If rs.EOF = False Then GetValuesV = rs.GetRows Else Throw New System.Exception("Query Return Empty Set") End If Catch ex As Exception Throw ex Finally rs.Close() cnn.Close() End Try End Function i'd like to have the error message up to test, but MsgBox("ERRORE: " + ex.Message) pops out something unexpected (Object variable or With block variable not set) What am i doing wrong here?? Thanks D

    Read the article

  • php: autoload exception handling.

    - by YuriKolovsky
    Hello again, I'm extending my previous question (Handling exceptions within exception handle) to address my bad coding practice. I'm trying to delegate autoload errors to a exception handler. <?php function __autoload($class_name) { $file = $class_name.'.php'; try { if (file_exists($file)) { include $file; }else{ throw new loadException("File $file is missing"); } if(!class_exists($class_name,false)){ throw new loadException("Class $class_name missing in $file"); } }catch(loadException $e){ header("HTTP/1.0 500 Internal Server Error"); $e->loadErrorPage('500'); exit; } return true; } class loadException extends Exception { public function __toString() { return get_class($this) . " in {$this->file}({$this->line})".PHP_EOL ."'{$this->message}'".PHP_EOL . "{$this->getTraceAsString()}"; } public function loadErrorPage($code){ try { $page = new pageClass(); echo $page->showPage($code); }catch(Exception $e){ echo 'fatal error: ', $code; } } } $test = new testClass(); ?> the above script is supposed to load a 404 page if the testClass.php file is missing, and it works fine, UNLESS the pageClass.php file is missing as well, in which case I see a "Fatal error: Class 'pageClass' not found in D:\xampp\htdocs\Test\PHP\errorhandle\index.php on line 29" instead of the "fatal error: 500" message I do not want to add a try/catch block to each and every class autoload (object creation), so i tried this. What is the proper way of handling this?

    Read the article

  • Appropriate use of die()?

    - by letseatfood
    I create pages in my current PHP project by using the following template: <?php include 'bootstrap.php'; head(); ?> <!-- Page content here --> <?php foot(); ?> Is the following example an appropriate use of die()? Also, what sort of problems might this cause for me, if any? <?php include 'bootstrap.php'; head(); try { //Simulate throwing an exception from some class throw new Exception('Something went wrong!'); } catch(Exception $e) { ?> <p>Please fix the following errors:</p> <p><?php echo $e->getMessage(); ?></p> <?php foot(); die(); } //If no exception is thrown above, continue script doSomething(); doSomeOtherThing(); foot(); ?> ?> <?php foot(); ?> Basically, I have a script with multiple tasks on it and I am trying to set up a graceful way to notify the user of input errors while preventing the remaining portion of the script from executing. Thanks!

    Read the article

  • Is catching general exceptions really a bad thing?

    - by Bob Horn
    I typically agree with most code analysis warnings, and I try to adhere to them. However, I'm having a harder time with this one: CA1031: Do not catch general exception types I understand the rationale for this rule. But, in practice, if I want to take the same action regardless of the exception thrown, why would I handle each one specifically? Furthermore, if I handle specific exceptions, what if the code I'm calling changes to throw a new exception in the future? Now I have to change my code to handle that new exception. Whereas if I simply caught Exception my code doesn't have to change. For example, if Foo calls Bar, and Foo needs to stop processing regardless of the type of exception thrown by Bar, is there any advantage in being specific about the type of exception I'm catching?

    Read the article

  • Try catch finally blocks.. do i still need them?

    - by Phil
    I am handling errors via my global.asax in this method: Dim CurrentException As Exception CurrentException = Server.GetLastError() Dim LogFilePath As String = Server.MapPath("~/Error/" & DateTime.Now.ToString("dd-MM-yy.HH.mm") & ".txt") Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(LogFilePath) sw.WriteLine(DateTime.Now.ToString) sw.WriteLine(CurrentException.ToString()) sw.Close() In my code I currently have no other error handling. Should I still insert try, catch, finally blocks? Thanks.

    Read the article

  • Exception Logging for WCF Services using ELMAH

    - by Ismail
    I tried this solution but I'm getting following exception System.ArgumentNullException was unhandled by user code Message="Value cannot be null.\r\nParameter name: context" Source="Elmah" ParamName="context" StackTrace: at Elmah.ErrorSignal.FromContext(HttpContext context) in c:\builds\ELMAH\src\Elmah\ErrorSignal.cs:line 67 at Elmah.ErrorSignal.FromCurrentContext() in c:\builds\ELMAH\src\Elmah\ErrorSignal.cs:line 61 at ElmahHttpErrorHandler.ProvideFault(Exception error, MessageVersion version, Message& fault) in c:\Myapplication\App_Code\Util\ElmahHttpErrorHandler.cs:line 19 at System.ServiceModel.Dispatcher.ErrorBehavior.ProvideFault(Exception e, FaultConverter faultConverter, ErrorHandlerFaultInfo& faultInfo) at System.ServiceModel.Dispatcher.ErrorBehavior.ProvideMessageFaultCore(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessageCleanup(MessageRpc& rpc) InnerException:

    Read the article

  • How to catch all exceptions in Flex?

    - by Yaba
    When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working. So for supportability reasons, I would like to catch any exception that can happen anywhere in the Flex UI and present an error message in a Flex internal popup. By using Java I would just encapsulate the whole UI code in a try/catch block, but with MXML applications in Flex I do not know, where I could perform such a general try/catch.

    Read the article

  • Logging exceptions in WCF with IErrorHandler inside HandleError or ProvideFault?

    - by Dannerbo
    I'm using IErrorHandler to do exception handling in WCF and now I want to log the exceptions, along with the stack trace and the user that caused the exception. I've read everywhere to put the logging in the HandleError method, and not the ProvideFault method. My question is, why? The only way I can see to get the user that caused the exception is: OperationContext.Current.IncomingMessageProperties.Security.ServiceSecurityContext.PrimaryIdentity ...But this only seems to work inside ProvideFault, and not inside HandleError. Is there a way to get the user inside HandleError?

    Read the article

  • LINQ error when deployed - Security Exception - cannot create DataContext

    - by aximili
    The code below works locally, but when I deploy it to the server it gives the following error. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. The code is protected void Page_Load(object sender, EventArgs e) { DataContext context = new DataContext(Global.ConnectionString); // <-- throws the exception //Table<Group> _kindergartensTable = context.GetTable<Group>(); Response.Write("ok"); } I have set full write permissons on all files and folders on the server. Any suggestions how to solve this problem? Thanks in advance.

    Read the article

  • When to log exception?

    - by Rune
    try { // Code } catch (Exception ex) { Logger.Log("Message", ex); throw; } In the case of a library, should I even log the exception? Should I just throw it and allow the application to log it? My concern is that if I log the exception in the library, there will be many duplicates (because the library layer will log it, the application layer will log it, and anything in between), but if I don't log it in the library, it'll be hard to track down bugs. Is there a best practices for this?

    Read the article

  • C# File Exception: cannot access the file because it is being used by another process

    - by Lirik
    I'm trying to download a file from the web and save it locally, but I get an exception: C# The process cannot access the file 'blah' because it is being used by another process. This is my code: File.Create("data.csv"); // create the file request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); request.Timeout = 30000; response = (HttpWebResponse)request.GetResponse(); using (Stream file = File.OpenWrite("data.csv"), // <-- Exception here input = response.GetResponseStream()) { // Save the file using Jon Skeet's CopyStream method CopyStream(input, file); } I've seen numerous other questions with the same exception, but none of them seem to apply here. Any help?

    Read the article

  • How to log python exception ?

    - by Maxim Veksler
    Hi, Coming from java, being familiar with logback I used to do try { ... catch (Exception e) { log("Error at X", e); } I would like the same functionality of being able to log the exception and the stacktrace into a file. How would you recommend me implementing this? Currently using boto logging infrastructre, boto.log.info(...) I've looked at some options and found out I can access the actual exception details using this code: import sys try: 1/0 except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback) I would like to somehow get the string print_exception() throws to stdout so that I can log it. Thank you, Maxim.

    Read the article

  • JNI_CreateJavaVM: Buffer overrun if I throw an exception in case of failure

    - by Dominik Fretz
    Hi, In a C++ project, I use the JNI invocation API to launch a JVM. I've done a little wrapper arount the JVM so I can use all the needed parts in a OO fashion. So far that works great. Now, if the JVM does not start (JNI_CreateJavaVM returns a value < 0) I'd like to raise an exception within my C++ code.But if I throw an exception after JNI_CreateJavaVM, I get a buffer overrun. If I raise the exception without the JNI_CreateJavaVM call, it works as expected. Does anyone have a clue on what the issue could be here? Or how to debug this? Environment: Windows, Visual Studio 2008 JDK: jrockit27.6jdk16005, but happens with SUN stock one as well Cheers Dominik

    Read the article

  • Interface "not marked with serializable attribute" exception

    - by Joel in Gö
    I have a very odd exception in my C# app: when trying to deserialize a class containing a generic List<IListMember> (where list entries are specified by an interface), an exception is thrown reporting that "the type ...IListMember is not marked with the serializable attribute" (phrasing may be slightly different, my VisualStudio is not in English). Now, interfaces cannot be Serializable; the class actually contained in the list, implementing IListMember, is [Serializable]; and yes, I have checked that IListMember is in fact defined as an interface and not accidentally as a class! I have tried reproducing the exception in a separate test project only containing the class containing the List and the members, but there it serializes and deserializes happily :/ Does anyone have any good ideas about what it could be?

    Read the article

  • How to stop .Net HttpWebRequest.GetResponse() raising an exception

    - by James
    Surely, surely, surely there is a way to configure the .Net HttpWebRequest object so that it does not raise an exception when HttpWebRequest.GetResponse() is called and any 300 or 400 status codes are returned? Jon Skeet does not think so, so I almost dare not even ask, but I find it hard to believe there is no way around this. 300 and 400 response codes are valid responses in certain circumstances. Why would we be always forced to incur the overhead of an exception? Perhaps there is some obscure configuration setting that evaded Jon Skeet? Perhaps there is a completely different type of request object that can be used that does not have this behavior? (and yes, I know you can just catch the exception and get the response from that, but I would like to find a way not to have to). Thanks for any help

    Read the article

  • Exception declared on ANTLR grammar rule ignored

    - by Kaleb Pederson
    I have a tree parser that's doing semantic analysis on the AST generated by my parser. It has a rule declared as follows: transitionDefinition throws WorkflowStateNotFoundException: /* ... */ This compiles just fine and matches the rule syntax at the ANTLR Wiki but my exception is never declared so the Java compiler complains about undeclared exceptions. ./tool/src/main/antlr3/org/antlr/grammar/v3/ANTLRv3.g shows that it's building a tree (but I'm not actually positive if it's the v2 or v3 grammar that ANTLR 3.2 is using): throwsSpec : 'throws' id ( ',' id )* -> ^('throws' id+) ; I know I can make it a runtime exception, but I'd like to use my exception hierarchy. Am I doing something wrong or should that syntax work?

    Read the article

  • 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

  • Handling multiple exceptions

    - by the-banana-king
    Hi there, I have written a class which loads configuration objects of my application and keeps track of them so that I can easily write out changes or reload the whole configuration at once with a single method call. However, each configuration object might potentially throw an exception when doing IO, yet I do not want those errors to cancel the overall process so that the other objects are still given a chance to reload/write. Therefore I collect all exceptions which are thrown while iterating over the objects and store them in a super-exception, which is thrown after the loop, since each exception must still be handled and someone has to be notified of what exactly went wrong. However, that approach looks a bit odd to me. Someone out there with a cleaner solution? Here is some code of the mentioned class: public synchronized void store() throws MultipleCauseException { MultipleCauseException me = new MultipleCauseException("unable to store some resources"); for(Resource resource : this.resources.values()) { try { resource.store(); } catch(StoreException e) { me.addCause(e); } } if(me.hasCauses()) throw me; }

    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

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