Skip to content
Advertisement

Tag: exception

Tool to extract java stack traces from log files [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 4 years ago. Improve this question Is there any tool that can extract a list of stack

in which namespace / package to put exceptions?

What is the common or best practice to structure the location of your exception classes? Let’s say you have the packages/namespaces myproject.person (models and DAOs for persons) and myproject.order (models and DAOs for orders) and the exceptions PersonException and OrderException. Should I put the exceptions in their corresponding packages or in a separate package for exceptions (e.g. myproject.exceptions)? The first

Java – find the first cause of an exception

I need to check if an exception is caused by some database problem. I receive an Exception and check if its cause contains the “ORA” string and return that (something like “ORA-00001”). The problem here is that the exception I receive is nested inside other exceptions, so if I don’t find out if it’s an oracle exception, I have to

What are all the possible values for SQLException.getSQLState?

SQLException.getSQLState retrieves the SQLState for the SQLException object. What are all the possible values that can be returned by this method? Can I use the value to identify specific errors that occurred in the database (i.e. can this value tell me if it was a PK violation, or a unique constraint, or column value too large, etc.)? Also, the DatabaseMetaData.getSQLStateType()

How can I avoid ResultSet is closed exception in Java?

As soon as my code gets to my while(rs.next()) loop it produces the ResultSet is closed exception. What causes this exception and how can I correct for it? EDIT: I notice in my code that I am nesting while(rs.next()) loop with another (rs2.next()), both result sets coming from the same DB, is this an issue? Answer Sounds like you executed

Should Exceptions be placed in a separate package?

I am taking on a project where all the Exceptions have been placed in a separate package com.myco.myproj.exceptions. Is this good practice? Answer I would expect the exceptions for a package to exist within that package. e.g. would contain pricing models and related exceptions. Anything else seems a bit counter-intuitive.

Best way to check whether a certain exception type was the cause (of a cause, etc …) in a nested exception?

I am writing some JUnit tests that verify that an exception of type MyCustomException is thrown. However, this exception is wrapped in other exceptions a number of times, e.g. in an InvocationTargetException, which in turn is wrapped in a RuntimeException. What’s the best way to determine whether MyCustomException somehow caused the exception that I actually catch? I would like to

Advertisement