Example usage for javax.mail.internet AddressException getPos

List of usage examples for javax.mail.internet AddressException getPos

Introduction

In this page you can find the example usage for javax.mail.internet AddressException getPos.

Prototype

public int getPos() 

Source Link

Document

Get the position with the reference string where the error was detected (-1 if not relevant).

Usage

From source file:com.rodaxsoft.mailgun.ListMemberRequest.java

/**
 * Set the list member email address//from   w w w. j  av  a 2 s .c  o  m
 * @param address The email address to set
 * @return ListMemberRequest object
 * @throws ContextedRuntimeException if the address format is invalid.
 * 
 */
public ListMemberRequest setAddress(String address) {
    try {
        new InternetAddress(address, true);
    } catch (AddressException e) {
        throw new ContextedRuntimeException(e).addContextValue("address", address).addContextValue("position",
                e.getPos());
    }

    parameters.put(ADDRESS_KEY, address);
    return this;
}

From source file:com.rodaxsoft.mailgun.ListMember.java

/**
 * Sets the email address//w ww.j a  v  a2 s. com
 * @param address The email address to set
 * @throws ContextedRuntimeException if the email address format is invalid
 */
public void setAddress(String address) {

    try {
        new InternetAddress(address, true);
    } catch (AddressException e) {
        throw new ContextedRuntimeException(e).addContextValue("address", address).addContextValue("position",
                e.getPos());
    }

    this.address = address;
}

From source file:nl.nn.adapterframework.core.IbisException.java

public String getExceptionSpecificDetails(Throwable t) {
    String result = null;/*from   www .j  a  v a  2s.c  o  m*/
    if (t instanceof AddressException) {
        AddressException ae = (AddressException) t;
        String parsedString = ae.getRef();
        if (StringUtils.isNotEmpty(parsedString)) {
            result = addPart(result, " ", "[" + parsedString + "]");
        }
        int column = ae.getPos() + 1;
        if (column > 0) {
            result = addPart(result, " ", "at column [" + column + "]");
        }
    }
    if (t instanceof SAXParseException) {
        SAXParseException spe = (SAXParseException) t;
        int line = spe.getLineNumber();
        int col = spe.getColumnNumber();
        String sysid = spe.getSystemId();

        String locationInfo = null;
        if (StringUtils.isNotEmpty(sysid)) {
            locationInfo = "SystemId [" + sysid + "]";
        }
        if (line >= 0) {
            locationInfo = addPart(locationInfo, " ", "line [" + line + "]");
        }
        if (col >= 0) {
            locationInfo = addPart(locationInfo, " ", "column [" + col + "]");
        }
        result = addPart(locationInfo, ": ", result);
    }
    if (t instanceof TransformerException) {
        TransformerException te = (TransformerException) t;
        SourceLocator locator = te.getLocator();
        if (locator != null) {
            int line = locator.getLineNumber();
            int col = locator.getColumnNumber();
            String sysid = locator.getSystemId();

            String locationInfo = null;
            if (StringUtils.isNotEmpty(sysid)) {
                locationInfo = "SystemId [" + sysid + "]";
            }
            if (line >= 0) {
                locationInfo = addPart(locationInfo, " ", "line [" + line + "]");
            }
            if (col >= 0) {
                locationInfo = addPart(locationInfo, " ", "column [" + col + "]");
            }
            result = addPart(locationInfo, ": ", result);
        }
    }
    if (t instanceof SQLException) {
        SQLException sqle = (SQLException) t;
        int errorCode = sqle.getErrorCode();
        String sqlState = sqle.getSQLState();
        if (errorCode != 0) {
            result = addPart("errorCode [" + errorCode + "]", ", ", result);
        }
        if (StringUtils.isNotEmpty(sqlState)) {
            result = addPart("SQLState [" + sqlState + "]", ", ", result);
        }
    }
    return result;
}