Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: how to throw

  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to throw

    I have this code ... The compiler instructed "unreported exception; must be caught or thrown". So I put the stmts in the following try/catch block. I'd like to throw the exception, not catch it, but am not sure of the syntax. The error msg is being written correctly to the logfile. This is the msg I want to throw.


    try {
    AttributedObject[] AttObjArray = super.getRelations(XML_NAME_RELATOR_CONTENT);
    AttributedObject attrObj = AttObjArray[0];

    AttributeData field = attrObj.getAttribute(XML_SALES_SUMMARY);
    AttributeDefinitionData field2 = field.getAttributeDefinition();


    logger.debug("Content Length Validations - begin");
    //Content Length validations
    if (!fieldLengthCheck(XML_SALES_SUMMARY,1000,(AttributedObject) attrObj))
    throw new ValidationException(this,new Exception(dispName + " can be no more than " + fld_maxLen + " characters."));
    if (!fieldLengthCheck(XML_ADDITIONAL_DESC,1000,attrObj))
    throw new ValidationException(this,new Exception(dispName + " can be no more than " + fld_maxLen + " characters."));

    logger.debug("Content Length Validations - end");

    } catch (Exception e) { logger.debug("get e.Msg: " + e.getMessage()); }

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    in your class definition use something like

    public class myClass() throws IOException {
    //code here
    }
    just replace IOException with the exception you need to throw

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks! - that worked


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •