Examples of InvalidDataException


Examples of com.cedarsolutions.exception.InvalidDataException

        assertNull(caller.result);
    }

    /** Test onUnhandledError() for general RPC error (unhandled validation error). */
    @Test public void testOnUnhandledError8() {
        Throwable exception = new InvalidDataException("Whatever");
        Caller caller = new Caller();
        caller.onUnhandledError(exception);

        assertEquals("generateGeneralRpcError", caller.error.getMessage());
        assertNull(caller.statusCode);
View Full Code Here

Examples of com.cedarsolutions.exception.InvalidDataException

                return element.getValue();
            }
        } catch (JAXBException e) {
            throw translateJaxbUnmarshalError(type, e);
        } catch (SAXException e) {
            InvalidDataException invalid = getUnmarshalError(type, e);
            invalid.getDetails().addMessage(ERROR_KEY, e.getMessage());
            throw invalid;
        }
    }
View Full Code Here

Examples of com.cedarsolutions.exception.InvalidDataException

    }

    /** Get a "raw" invalid data exception for a class, with empty details attached. */
    private static <T> InvalidDataException getUnmarshalError(Class<T> type, Throwable cause) {
        ValidationErrors details = new ValidationErrors(ERROR_KEY, "Error unmarshalling XML for " + type.getSimpleName());
        return new InvalidDataException("Error unmarshalling XML for " + type.getSimpleName(), details);
    }
View Full Code Here

Examples of com.cedarsolutions.exception.InvalidDataException

        }
    }

    /** Generate a JAXB unmarshal exception due to validation problems. */
    private static <T> InvalidDataException generateValidationError(Class<T> type, ValidationEventCollector eventHandler) {
        InvalidDataException invalid = getUnmarshalError(type, null);

        invalid.getDetails().addMessage(ERROR_KEY, "Found validation errors");
        for (ValidationEvent event : eventHandler.getEvents()) {
            invalid.getDetails().addMessage(ERROR_KEY, event.getMessage());
        }
        return invalid;
    }
View Full Code Here

Examples of com.cedarsolutions.exception.InvalidDataException

    }

    /** Translate a JAXB unmarshal exception into something legible. */
    private static <T> InvalidDataException translateJaxbUnmarshalError(Class<T> type, JAXBException e) {
        boolean added = false;
        InvalidDataException invalid = getUnmarshalError(type, e);

        // This was developed through trial-and-error.  I don't know how well it will hold up in the future.
        if (e.getCause() != null && e.getLinkedException() != null) {
            try {
                throw e.getLinkedException();
            } catch (org.xml.sax.SAXParseException sax) {
                String message = "Line " + sax.getLineNumber() + ", column " + sax.getColumnNumber() + ": " + e.getCause().getMessage();
                invalid.getDetails().addMessage(ERROR_KEY, message);
                added = true;
            } catch (Throwable other) { }
        }

        if (!added && e.getCause() != null && e.getCause().getMessage() != null) {
            invalid.getDetails().addMessage(ERROR_KEY, e.getCause().getMessage());
            added = true;
        }

        if (!added && e.getMessage() != null) {
            invalid.getDetails().addMessage(ERROR_KEY, e.getMessage());
            added = true;
        }

        return invalid;
    }
View Full Code Here

Examples of com.cedarsolutions.exception.InvalidDataException

            FileInputStream stream = null;
            try {
                stream = new FileInputStream(path);
                properties.load(stream);
            } catch (Exception e) {
                throw new InvalidDataException("Properties could not be loaded: " + e.getMessage(), e);
            } finally {
                if (stream != null) {
                    try {
                        stream.close();
                    } catch (Exception e) { }
View Full Code Here

Examples of com.cedarsolutions.exception.InvalidDataException

                                return cookie;
                            } else {
                                cookieToReturn = cookie;
                            }
                        } else {
                            throw new InvalidDataException("Duplicate cookie [" + cookieName + "]: possible cookie override attack?");
                        }
                    }
                }
            }
        }
View Full Code Here

Examples of com.intellij.openapi.util.InvalidDataException

      }
      else if (DOUBLE_CLICK.equals(token)) {
        clickCount = 2;
      }
      else {
        throw new InvalidDataException("unknown token: " + token);
      }
    }
    return new MouseShortcut(button, modifiers, clickCount);
  }
View Full Code Here

Examples of com.knife.Math.exception.InvalidDataException

   * @throws InvalidDataException
   */
  public static long invertNumber(long input) throws InvalidDataException {
    long result = 0;
    if (input == 0) {
      throw new InvalidDataException("A value of 0 cannot be inverted");
    }
    if (input > 0) {
      String temp = "-" + String.valueOf(input);
      result = Long.parseLong(temp);
    } else {
View Full Code Here

Examples of com.rackspacecloud.blueflood.exceptions.InvalidDataException

    public Metric(Locator locator, Object metricValue, long collectionTime, TimeValue ttl, String unit) {
        this.locator = locator;
        this.metricValue = metricValue;
        // I dislike throwing errors in constructors, but there is no other way without resorting to a json schema.
        if (collectionTime < 0) {
            throw new InvalidDataException("collection time must be greater than zero");
        }
        this.collectionTime = collectionTime;
        this.dataType = DataType.getMetricType(metricValue);
        this.unit = unit;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.