Search Results

Search found 4116 results on 165 pages for 'baron throw'.

Page 22/165 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • What to do of exceptions when implementing java.lang.Iterator

    - by Vincent Robert
    The java.lang.Iterator interface has 3 methods: hasNext, next and remove. In order to implement a read-only iterator, you have to provide an implementation for 2 of those: hasNext and next. My problem is that these methods does not declare any exceptions. So if my code inside the iteration process declares exceptions, I must enclose my iteration code inside a try/catch block. My current policy has been to rethrow the exception enclosed in a RuntimeException. But this has issues because the checked exceptions are lost and the client code no longer can catch those exceptions explicitly. How can I work around this limitation in the Iterator class? Here is a sample code for clarity: class MyIterator implements Iterator { @Override public boolean hasNext() { try { return implementation.testForNext(); } catch ( SomethingBadException e ) { throw new RuntimeException(e); } } @Override public boolean next() { try { return implementation.getNext(); } catch ( SomethingBadException e ) { throw new RuntimeException(e); } } ... }

    Read the article

  • System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

    - by sachin kulkarni
    I have installed Oracle client version 10g on my PC(Registry ORACLE_BASE-D:\oracle\product\10.2.0). I have added below references. System.Data.OracleClient. I am getting above mentioned error. Below is the Code Snippet . public static OracleConnection getConnection() { try { dataSource = new SqlDataSource(); dataSource.ConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("conn"); OracleConnection connection = new OracleConnection(); if (dataSource == null) { // Error during initialization of InitialContext or Datasource throw new Exception("###### Fatal Exception ###### - DataSource is not initialized.Pls check the stdout/logs."); } else { connection.ConnectionString = dataSource.ConnectionString; connection.Open(); } return connection; }catch (Exception ex) { throw ex; } } Please let me know what are the areas of Concern and where Iam missing.I am new for the combination of Oracle and Asp.Net.

    Read the article

  • Throwing Exception in CTOR and Smart Pointers

    - by David Relihan
    Is it OK to have the following code in my constructor to load an XML document into a member variable - throwing to caller if there are any problems: MSXML2::IXMLDOMDocumentPtr m_docPtr; //member Configuration() { try { HRESULT hr = m_docPtr.CreateInstance(__uuidof(MSXML2::DOMDocument40)); if ( SUCCEEDED(hr)) { m_docPtr->loadXML(CreateXML()); } else { //throw exception to caller } } catch(...) { //throw exception to caller } } Based on Scott Myers RAII implementations in More Effective C++ I believe I am alright in just allowing exceptions to be thrown from CTOR as I am using a smart pointer(IXMLDOMDocumentPtr). Let me know what you think....

    Read the article

  • Weird bug in Java try-catch-finally

    - by kcr
    I'm using JODConverter to convert .xls and .ppt to .pdf format. For this i have code something like try{ //do something System.out.println("connecting to open office"); OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100); System.out.println("connection object created"); connection.connect(); System.out.println("connection to open office successful"); //do something if(!successful) throw new FileNotFoundException(); }catch(Exception e){ System.out.println("hello here"); System.out.println("Caught Exception while converting to PDF "); LOGGER.error("Error in converting media" + e.getMessage()); throw new MediaConversionFailedException(); }finally{ decode_pdf.closePdfFile(); System.out.println("coming in finally"); //do something here } My Output : connecting to open office connection object created coming in finally P.S. return type of method is void How is it possible ? Even if there is some problem in connection.connect(), it s'd come in catch block. confused

    Read the article

  • Move constructor and assignment operator: why no default for derived classes?

    - by doublep
    Why there is default move constructor or assignment operator not created for derived classes? To demonstrate what I mean; having this setup code: #include <utility> struct A { A () { } A (A&&) { throw 0; } A& operator= (A&&) { throw 0; } }; struct B : A { }; either of the following lines throws: A x (std::move (A ()); A x; x = A (); but neither of the following does: B x (std::move (B ()); B x; x = B (); In case it matters, I tested with GCC 4.4.

    Read the article

  • If XmlException.SourceUri is read-only, what good is it?

    - by East of Nowhere
    I have a couple places in my code where it throwing a new System.Xml.XmlException seems appropriate. I could just do throw new XmlException("Your XML sucks go fix it then try again."); But I think it's better to take advantage whenever possible of members particular to the exception class (otherwise ya might as well throw a plain ol' Exception every time). SourceUri and LineNumber would be helpful, but they only have get methods, there's no way I can assign a value to them! There's only 3 constructor overloads and none of them have parameters for those members either; I can only initialize Message, nothing else. There has got to be some way to populate those data members with values, otherwise why does XmlException bother with them? I suppose I could make a new class that inherits XmlException and write a new constructor that initializes SourceUri etc. but still, there must be a way to just use XmlException. Right?

    Read the article

  • C# MDX RenderToSurface, where to reset after device is lost?

    - by Moritz Schöfl
    Hi, I got a problem with the RenderToSurface class. When I resize the Form of my Device, the Draw method is still called, but doesnt throw an Exception, it looks like this: device.Clear(ClearFlags.Target, Color.Red, 0, 0); device.BeginScene(); // here is out commented code device.EndScene(); device.Present(); In another method, I wrote this: renderToSurface.BeginScene(surfaces[currentIndex]); // here is out commented code renderToSurface.EndScene(Filter.None); and this method seems to throw a nullpointer exception when I resize the window; So my question is: - where to reset / restore / handle the renderToSurface class? (i tried it with the DeviceReset event like following - void OnDeviceReset(object sender, EventArgs e) { renderToSurface = new RenderToSurface(Game.Device, Game.ClientSize.Width, Game.ClientSize.Height, Format.A8R8G8B8, true, DepthFormat.D16); } )

    Read the article

  • Implement Exception Handling in ASP.NET C# Project

    - by Shrewd Demon
    hi, I have an application that has many tiers. as in, i have... Presentation Layer (PL) - contains all the html My Codes Layer (CL) - has all my code Entity Layer (EL) - has all the container entities Business Logic Layer (BLL) - has the necessary business logic Data Logic Layer (DLL) - any logic against data Data Access Layer (DAL) - one that accesses data from the database Now i want to provide error handling in my DLL since it is responsible for executing statement like ExecureScalar and all.... And i am confused as to how to go about it...i mean do i catch the error in the DLL and throw it back to the BLL and from there throw it back to my code or what.... can any one please help me how do i implement a clean and easy error handling techinque help you be really appreciated. Thank you.

    Read the article

  • PHP Nested classes work... sort of?

    - by SeanJA
    So, if you try to do a nested class like this: //nestedtest.php class nestedTest{ function test(){ class E extends Exception{} throw new E; } } You will get an error Fatal error: Class declarations may not be nested in [...] but if you have a class in a separate file like so: //nestedtest2.php class nestedTest2{ function test(){ include('e.php'); throw new E; } } //e.php class E Extends Exception{} So, why does the second hacky way of doing it work, but the non-hacky way of doing it does not work?

    Read the article

  • Exceptions and web services

    - by Schildmeijer
    Im using the standard java ws implementation shipped with e.g. java6 (javax.jws.*). I have the following: import javax.jws.*; @WebService(name="Widget") public interface Widget { @WebMethod public @WebResult String getGadget(@WebParam(name = "id") long id) throw MyOwnException; } Is this possible? Do I have to annotate MyOwnException with e.g the @WebFault annotation? During my initial tests I also noticed that, on the client side, the autogenerated MyOwnException was renamed to MyOwnException_Exception and wrapped the "original" MyOwnException. Or if this is a bad idea, are there any recommended Exceptions to throw from a webservice like this?

    Read the article

  • Multiple schema validation in Java

    - by user279554
    Hi, I am trying to do multiple schema validation in Java. I don't understand where I am doing wrong. Any help will be appreciated. abc.xsd <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xn="project-xml-r4j_another.xsd"> <xsd:import namespace="project-xml-r4j_another.xsd"/> <xsd:element name="abc" type="abc"> </xsd:element> <xsd:complexType name="abc"> <xsd:sequence> <xsd:element name="test" type="test" minOccurs="0" maxOccurs="1"> </xsd:element> <!--<xsd:element name="proj" type="xn:proj"/>--> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID" use="required"/> </xsd:complexType> <xsd:complexType name="test"> <xsd:attribute name="id" type="xsd:ID" use="required"></xsd:attribute> <xsd:attribute name="value" use="required"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="100" /> </xsd:restriction> </xsd:simpleType> </xsd:attribute> </xsd:complexType> </xsd:schema> project-xml-r4j_another.xsd <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="project-xml-r4j_another.xsd" xmlns="project-xml-r4j_another.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:element name="proj" type="proj"> <xsd:annotation> <xsd:documentation> The project is the root tag of a project-xml. </xsd:documentation> </xsd:annotation> </xsd:element> <xsd:complexType name="proj"> <xsd:attribute name="id" type="xsd:ID" use="required"/> </xsd:complexType> </xsd:schema> Test case package test; import java.io.File; import java.io.IOException; import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; import org.apache.log4j.Logger; import org.junit.Test; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; import com.ericsson.ccrtool.core.project.projectxml.InvalidProjectXmlException; public class TestSchema { private static final Logger logger = Logger.getLogger(TestSchema.class); static final String W3C_XML_SCHEMA = XMLConstants.W3C_XML_SCHEMA_NS_URI; @Test public void test() { System.out.println("TestSchema.test()"); try { SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA); // create a grammar object. Source [] source = { new StreamSource(new File("C:\\jaydeep\\Ericsson\\R5B\\abc.xsd")), new StreamSource(new File("C:\\jaydeep\\Ericsson\\R5B\\project-xml-r4j.xsd"))}; Schema schemaGrammar = schemaFactory.newSchema(source); Validator schemaValidator = schemaGrammar.newValidator(); schemaValidator.setErrorHandler(new MessageHandler()); // validate xml instance against the grammar. schemaValidator.validate(new StreamSource("C:\\jaydeep\\Ericsson\\R5B\\project_tmmk17cells_xnaveen_project-xml.xml")); } catch (SAXException e) { throw new InvalidProjectXmlException("Project-xml validation failed, Exception: " + e.getMessage(), e); } catch (IOException e) { throw new InvalidProjectXmlException("Project-xml validation failed, Exception: " + e.getMessage(), e); } } class MessageHandler extends DefaultHandler { private String errMessage = ""; @Override public void warning(SAXParseException e) { logger.info("Warning Line " + e.getLineNumber() + ": " + e.getMessage()); } @Override public void error(SAXParseException e) { errMessage = new String("Error Line " + e.getLineNumber() + ": " + e.getMessage()); logger.info(errMessage); throw new InvalidProjectXmlException("Project-xml validation failed, Exception: " + errMessage); } @Override public void fatalError(SAXParseException e) { errMessage = new String("Error Line " + e.getLineNumber() + ": " + e.getMessage()); logger.info(errMessage); throw new InvalidProjectXmlException("Project-xml validation failed, Exception: " + errMessage); } } } Thanks, Jaydeep

    Read the article

  • How can I configure a Factory with the possible providers?

    - by Jonathas Costa
    I have three assemblies: "Framework.DataAccess", "Framework.DataAccess.NHibernateProvider" and "Company.DataAccess". Inside the assembly "Framework.DataAccess", I have my factory (with the wrong implementation of discovery): public class DaoFactory { private static readonly object locker = new object(); private static IWindsorContainer _daoContainer; protected static IWindsorContainer DaoContainer { get { if (_daoContainer == null) { lock (locker) { if (_daoContainer != null) return _daoContainer; _daoContainer = new WindsorContainer(new XmlInterpreter()); // THIS IS WRONG! THIS ASSEMBLY CANNOT KNOW ABOUT SPECIALIZATIONS! _daoContainer.Register( AllTypes.FromAssemblyNamed("Company.DataAccess") .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(), AllTypes.FromAssemblyNamed("Framework.DataAccess.NHibernateProvider") .BasedOn(typeof(IReadDao<>)).WithService.Base()); } } return _daoContainer; } } public static T Create<T>() where T : IDao { return DaoContainer.Resolve<T>(); } } This assembly also defines the base interface for data access IReadDao: public interface IReadDao<T> { IEnumerable<T> GetAll(); } I want to keep this assembly generic and with no references. This is my base data access assembly. Then I have the NHibernate provider's assembly, which implements the above IReadDao using NHibernate's approach. This assembly references the "Framework.DataAccess" assembly. public class NHibernateDao<T> : IReadDao<T> { public NHibernateDao() { } public virtual IEnumerable<T> GetAll() { throw new NotImplementedException(); } } At last, I have the "Company.DataAccess" assembly, which can override the default implementation of NHibernate provider and references both previously seen assemblies. public interface IProductDao : IReadDao<Product> { Product GetByName(string name); } public class ProductDao : NHibernateDao<Product>, IProductDao { public override IEnumerable<Product> GetAll() { throw new NotImplementedException("new one!"); } public Product GetByName(string name) { throw new NotImplementedException(); } } I want to be able to write... IRead<Product> dao = DaoFactory.Create<IRead<Product>>(); ... and then get the ProductDao implementation. But I can't hold inside my base data access any reference to specific assemblies! My initial idea was to read that from a xml config file. So, my question is: How can I externally configure this factory to use a specific provider as my default implementation and my client implementation?

    Read the article

  • Why does a looser specification in an overriding method compile after the exception specification fo

    - by Everyone
    The code below has an overridden method with a looser exception specification as compared to the method being overridden. //AnotherMain.java public class AnotherMain { public void dummyMethod( String args[] ) throws IOException{ throw new IOException(); } } //SubAnotherMain.java public class SubAnotherMain extends AnotherMain{ @Override public void dummyMethod( String[] args ) throws Exception { // To get this to compile, change the above - throws IOException, Exception super.dummyMethod(args); throw new Exception("This will not compile unless the exception specification has IOException too"); } } Afaik, the overriding method should not compile at all as the looser specification might break substitutability. Why does it compile after the original exception specification is included in the override? What have I misunderstood?

    Read the article

  • Can someone explain this block of ASP.NET MVC code to me, please?

    - by Pure.Krome
    Hi folks, this is the current code in ASP.NET MVC2 (RTM) System.Web.Mvc.AuthorizeAttribute class :- public virtual void OnAuthorization(AuthorizationContext filterContext) { if (filterContext == null) { throw new ArgumentNullException("filterContext"); } if (this.AuthorizeCore(filterContext.HttpContext)) { HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; cache.SetProxyMaxAge(new TimeSpan(0L)); cache.AddValidationCallback( new HttpCacheValidateHandler(this.CacheValidateHandler), null); } else { filterContext.Result = new HttpUnauthorizedResult(); } } so if i'm 'authorized' then do some caching stuff, otherwise throw a 401 Unauthorized response. Question: What does those 3 caching lines do? cheers :)

    Read the article

  • Can i override an abstract method written in a parent class, with a different name in a child class?

    - by Ranhiru
    abstract class SettingSaver { public abstract void add(string Name, string Value); public abstract void remove(string SettingName); } class XMLSettings : SettingSaver { public override void add(string Name, string Value) { throw new NotImplementedException(); } public override void remove(string SettingName) { throw new NotImplementedException(); } } Is there anyway that I can change the name of the add function in XMLSettings class to addSetting but make sure it overrides the add function in the SettingSaver? I know it should be definitely overridden in derived classes but just want to know whether I can use a different name :) Thanx in advance :D

    Read the article

  • How do I implement a fibonacci sequence in java using try/catch logic?

    - by Lars Flyger
    I know how to do it using simple recursion, but in order to complete this particular assignment I need to be able to accumulate on the stack and throw an exception that holds the answer in it. So far I have: public static int fibo(int index) { int sum = 0; try { fibo_aux(index, 1, 1); } catch (IntegerException me) { sum = me.getIntValue(); } return sum; } fibo_aux is supposed to throw an IntegerException (which holds the value of the answer that is retireved via getIntValue) and accumulates the answer on the stack, but so far I can't figure it out. Can anyone help?

    Read the article

  • ASP.Net partially ignoring my Custom error section in web.config

    - by weevie
    Here's my web.config customErrors section (you'll notice I've switched the mode to 'On' so I can see the redirect on my localhost): <customErrors defaultRedirect="~/Application/ServerError.aspx" mode="On" redirectMode="ResponseRewrite"> <error statusCode="403" redirect="~/Secure/AccessDenied.aspx" /> </customErrors> and here's the code that throws: Catch adEx As AccessDeniedException Throw New HttpException(DirectCast(HttpStatusCode.Forbidden, Integer), adEx.Message) End Try and here's what I end up with: Which is not my pretty AccessDenied.aspx page but it is a forbidden error page so at least I know my throw is working. I've removed the entry for 403 in IIS (7.0) as a desperate last attempt and unsuprisingly that made no difference. I've run out of ideas now so any suggestions will be gratefully appreciated!

    Read the article

  • HttpPost request unsuccessful

    - by The Thom
    I have written a web service and am now writing a tester to perform integration testing from the outside. I am writing my tester using apache httpclient 4.3. Based on the code here: http://hc.apache.org/httpcomponents-client-4.3.x/quickstart.html and here: http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fundamentals.html#d5e186 I have written the following code. Map<String, String> parms = new HashMap<>(); parms.put(AirController.KEY_VALUE, json); postUrl(SERVLET, parms); ... protected String postUrl(String servletName, Map<String, String> parms) throws AirException{ String url = rootUrl + servletName; HttpPost post = new HttpPost(url); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); for(Map.Entry<String, String> entry:parms.entrySet()){ BasicNameValuePair parm = new BasicNameValuePair(entry.getKey(), entry.getValue()); nvps.add(parm); } try { post.setEntity(new UrlEncodedFormEntity(nvps)); } catch (UnsupportedEncodingException use) { String msg = "Invalid parameters:" + parms; throw new AirException(msg, use); } CloseableHttpResponse response; try { response = httpclient.execute(post); } catch (IOException ioe) { throw new AirException(ioe); } String result; if(HttpStatus.SC_OK == response.getStatusLine().getStatusCode()){ result = processResponse(response); } else{ String msg = MessageFormat.format("Invalid status code {0} received from query {1}.", new Object[]{response.getStatusLine().getStatusCode(), url}); throw new AirException(msg); } return result; } This code successfully reaches my servlet. In my servlet, I have (using Spring's AbstractController): protected ModelAndView post(HttpServletRequest request, HttpServletResponse response) { String json = String.valueOf(request.getParameter(KEY_VALUE)); if(json.equals("null")){ log.info("Received null value."); response.setStatus(406); return null; } And this code always falls into the null parameter code and returns a 406. I'm sure I'm missing something simple, but can't see what it is.

    Read the article

  • Mysql: ROLLBACK for multiple queries

    - by Raj
    Hi I have more than three MySql queiries in a PHP script triggered by scheduled task. If a query catch an error, script throw an exception and rollback that Mysql query. It works fine. However if first query works fine, but not 2nd query, throw an exception, it rollback 2nd one but not 1st query. I am using begin_trans(), commit and rollback() for individual queries because Sometimes i need to rollback one query, sometimes all queries. Is there any way to rollback one query or all queries? Thanks in advance UPDATE: I got it working, there was no problem with in begin_trans(), commit and rollback(), the database connection config was different for one query from other queries, crazy code without any comments!!!

    Read the article

  • How can I easily run different configurations in Eclipse?

    - by Roman
    I have an Java applications which I would like to run with different values of input parameters (specified in the command line). In "Run - Run Configurations" I have created different configurations corresponding to different values of the input arguments. I can run these configurations in the same way (throw "Run - Run Configurations"). But in these case I have to perform to many actions (clicks) to run a particular configuration. Is there a easier (faster) way to do that? For example I expect that I can do it throw "Run - Run as" but in the drop-dawn menu of the "Run as" I see "(Not Applicable)".

    Read the article

  • When do you trust the data / variables

    - by Wizzard
    We all know that all user data, GET/POST/Cookie etc etc needs to be validated for security. But when do you stop, once it's converted into a local variable? eg if (isValidxxx($_GET['foo']) == false) { throw InvalidArgumentException('Please enter a valid foo!'); } $foo = $_GET['foo']; fooProcessor($foo); function fooProcessor($foo) { if (isValidxxx($foo) == false) { throw Invalid...... } //other stuff } To me thats over the top. But what if you load the value from the database... I hope I make sense :)

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >