/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.internal.statesystem.core;
* The attribute doesn't exist, but we have been specified to NOT
* add any new attributes.
*/
- throw new AttributeNotFoundException();
+ throw new AttributeNotFoundException(ss.getSSID() + " Quark:" + startingNodeQuark + ", SubPath:" + Arrays.toString(subPath)); //$NON-NLS-1$ //$NON-NLS-2$
}
/*
* The attribute was already existing, return the quark of that
/* Check if the quark is valid */
if (attributeQuark < -1 || attributeQuark >= attributeList.size()) {
- throw new AttributeNotFoundException();
+ throw new AttributeNotFoundException(ss.getSSID() + " Quark:" + attributeQuark); //$NON-NLS-1$
}
/* Set up the node from which we'll start the search */
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.internal.statesystem.core;
stackDepth = previousSV.unboxInt();
} else {
/* Previous state of this attribute was another type? Not good! */
- throw new StateValueTypeException();
+ throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Type:" + previousSV.getType() + ", Expected:" + Type.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
if (stackDepth >= 100000) {
* Limit stackDepth to 100000, to avoid having Attribute Trees grow
* out of control due to buggy insertions
*/
- String message = "Stack limit reached, not pushing"; //$NON-NLS-1$
- throw new AttributeNotFoundException(message);
+ String message = " Stack limit reached, not pushing"; //$NON-NLS-1$
+ throw new AttributeNotFoundException(getSSID() + " Quark:" + attributeQuark + message); //$NON-NLS-1$
}
stackDepth++;
throws AttributeNotFoundException, TimeRangeException,
StateValueTypeException {
/* These are the state values of the stack-attribute itself */
- ITmfStateValue previousSV = queryOngoingState(attributeQuark);
+ ITmfStateValue previousSV = transState.getOngoingStateValue(attributeQuark);
if (previousSV.isNull()) {
/*
* The existing value was not an integer (which is expected for
* stack tops), this doesn't look like a valid stack attribute.
*/
- throw new StateValueTypeException();
+ throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Type:" + previousSV.getType() + ", Expected:" + Type.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
int stackDepth = previousSV.unboxInt();
if (stackDepth <= 0) {
/* This on the other hand should not happen... */
- String message = "A top-level stack attribute cannot " + //$NON-NLS-1$
- "have a value of 0 or less."; //$NON-NLS-1$
- throw new StateValueTypeException(message);
+ throw new StateValueTypeException(getSSID() + " Quark:" + attributeQuark + ", Stack depth:" + stackDepth); //$NON-NLS-1$//$NON-NLS-2$
}
/* The attribute should already exist at this point */
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.internal.statesystem.core;
private void checkValidAttribute(int quark) throws AttributeNotFoundException {
if (quark > fOngoingStateInfo.size() - 1 || quark < 0) {
- throw new AttributeNotFoundException();
+ throw new AttributeNotFoundException(fBackend.getSSID() + " Quark:" + quark); //$NON-NLS-1$
}
}
* but for every other types, it needs to match our
* expectations!
*/
- throw new StateValueTypeException();
+ throw new StateValueTypeException(fBackend.getSSID() + " Quark:" + quark + ", Type:" + value.getType() + ", Expected:" + expectedSvType); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
if (fOngoingStateInfo.get(quark).equals(value)) {
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2012, 2015 Ericsson, École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* All rights reserved. This program and the accompanying materials are
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
* Florian Wininger - Allow to change the size of a interval
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.internal.statesystem.core.backend.historytree;
public HTInterval(long intervalStart, long intervalEnd, int attribute,
TmfStateValue value) throws TimeRangeException {
if (intervalStart > intervalEnd) {
- throw new TimeRangeException();
+ throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$
}
this.start = intervalStart;
private HTInterval(long intervalStart, long intervalEnd, int attribute,
TmfStateValue value, int size) throws TimeRangeException {
if (intervalStart > intervalEnd) {
- throw new TimeRangeException();
+ throw new TimeRangeException("Start:" + intervalStart + ", End:" + intervalEnd); //$NON-NLS-1$ //$NON-NLS-2$
}
this.start = intervalStart;
/*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson, École Polytechnique de Montréal, and others
+ * Copyright (c) 2010, 2015 Ericsson, École Polytechnique de Montréal, and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
* Florian Wininger - Add Extension and Leaf Node
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.internal.statesystem.core.backend.historytree;
*/
public void insertInterval(HTInterval interval) throws TimeRangeException {
if (interval.getStartTime() < config.getTreeStart()) {
- throw new TimeRangeException();
+ throw new TimeRangeException("Interval Start:" + interval.getStartTime() + ", Config Start:" + config.getTreeStart()); //$NON-NLS-1$ //$NON-NLS-2$
}
tryInsertAtNode(interval, latestBranch.size() - 1);
}
/*******************************************************************************
- * Copyright (c) 2014 École Polytechnique de Montréal
+ * Copyright (c) 2014, 2015 École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Geneviève Bastien - Initial API and implementation
* Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.statesystem.core;
* This attribute is an integer attribute, but it doesn't seem like
* it's used as a stack-attribute...
*/
- throw new StateValueTypeException();
+ throw new StateValueTypeException(ss.getSSID() + " Quark:" + stackAttributeQuark + ", Stack depth:" + curStackDepth); //$NON-NLS-1$//$NON-NLS-2$
}
int subAttribQuark = ss.getQuarkRelative(stackAttributeQuark, String.valueOf(curStackDepth));
/* Make sure the time range makes sense */
if (t2 < t1) {
- throw new TimeRangeException();
+ throw new TimeRangeException(ss.getSSID() + " Start:" + t1 + ", End:" + t2); //$NON-NLS-1$ //$NON-NLS-2$
}
/* Set the actual, valid end time of the range query */
/* Make sure the time range makes sense */
if (t2 < t1 || resolution <= 0) {
- throw new TimeRangeException();
+ throw new TimeRangeException(ss.getSSID() + " Start:" + t1 + ", End:" + t2 + ", Resolution:" + resolution); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/* Set the actual, valid end time of the range query */
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
* Matthew Khouzam - Modified to use a TreeSet
+ * Patrick Tasse - Add message to exceptions
******************************************************************************/
package org.eclipse.tracecompass.statesystem.core.backend;
int quark, ITmfStateValue value) throws TimeRangeException {
/* Make sure the passed start/end times make sense */
if (stateStartTime > stateEndTime || stateStartTime < startTime) {
- throw new TimeRangeException();
+ throw new TimeRangeException(ssid + " Interval Start:" + stateStartTime + ", Interval End:" + stateEndTime + ", Backend Start:" + startTime); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
ITmfStateInterval interval = new TmfStateInterval(stateStartTime, stateEndTime, quark, value);
public void doQuery(List<ITmfStateInterval> currentStateInfo, long t)
throws TimeRangeException {
if (!checkValidTime(t)) {
- throw new TimeRangeException();
+ throw new TimeRangeException(ssid + " Time:" + t + ", Start:" + startTime + ", End:" + latestTime); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/*
public ITmfStateInterval doSingularQuery(long t, int attributeQuark)
throws TimeRangeException, AttributeNotFoundException {
if (!checkValidTime(t)) {
- throw new TimeRangeException();
+ throw new TimeRangeException(ssid + " Time:" + t + ", Start:" + startTime + ", End:" + latestTime); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/*
}
}
}
- throw new AttributeNotFoundException();
+ throw new AttributeNotFoundException(ssid + " Quark:" + attributeQuark); //$NON-NLS-1$
}
private boolean checkValidTime(long t) {
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.statesystem.core.backend.historytree;
@Override
public void doQuery(List<ITmfStateInterval> stateInfo, long t)
throws TimeRangeException, StateSystemDisposedException {
- if (!checkValidTime(t)) {
- /* We can't possibly have information about this query */
- throw new TimeRangeException();
- }
+ checkValidTime(t);
/* We start by reading the information in the root node */
HTNode currentNode = sht.getRootNode();
return getRelevantInterval(t, attributeQuark);
}
- private boolean checkValidTime(long t) {
- return (t >= sht.getTreeStart() && t <= sht.getTreeEnd());
+ private void checkValidTime(long t) {
+ long treeStart = sht.getTreeStart();
+ long treeEnd = sht.getTreeEnd();
+ if (t < treeStart || t > treeEnd) {
+ throw new TimeRangeException(ssid + " Time:" + t + ", Start:" + treeStart + ", End:" + treeEnd); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
}
/**
*/
private HTInterval getRelevantInterval(long t, int key)
throws TimeRangeException, StateSystemDisposedException {
- if (!checkValidTime(t)) {
- throw new TimeRangeException();
- }
+ checkValidTime(t);
HTNode currentNode = sht.getRootNode();
HTInterval interval = currentNode.getRelevantInterval(key, t);
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.statesystem.core.exceptions;
super(message);
}
+ /**
+ * Constructor with both a message and a cause.
+ *
+ * @param message
+ * Message to attach to this exception
+ * @param e
+ * Cause of this exception
+ * @since 1.0
+ */
+ public AttributeNotFoundException(String message, Throwable e) {
+ super(message, e);
+ }
}
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2015 Ericsson
* Copyright (c) 2010, 2011 École Polytechnique de Montréal
* Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
*
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.statesystem.core.exceptions;
private static final long serialVersionUID = -4067685227260254532L;
+ /**
+ * Default constructor
+ */
+ public TimeRangeException() {
+ }
+
+ /**
+ * Constructor with a message
+ *
+ * @param message
+ * Message to attach to this exception
+ * @since 1.0
+ */
+ public TimeRangeException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with both a message and a cause.
+ *
+ * @param message
+ * Message to attach to this exception
+ * @param e
+ * Cause of this exception
+ * @since 1.0
+ */
+ public TimeRangeException(String message, Throwable e) {
+ super(message, e);
+ }
}
/*******************************************************************************
- * Copyright (c) 2014 Ecole Polytechnique de Montreal
+ * Copyright (c) 2014, 2015 Ecole Polytechnique de Montreal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Florian Wininger - Initial API and implementation
* Naser Ezzati - Add the comparison operators
+ * Patrick Tasse - Add message to exceptions
******************************************************************************/
package org.eclipse.tracecompass.tmf.analysis.xml.core.model;
* check
*/
if (quark == IXmlStateSystemContainer.ERROR_QUARK) {
- throw new AttributeNotFoundException();
+ throw new AttributeNotFoundException(ss.getSSID() + " Attribute:" + attribute); //$NON-NLS-1$
}
}
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
*
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
+ * Patrick Tasse - Add message to exceptions
*******************************************************************************/
package org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial;
fPartialSS.getUpstreamSS().waitUntilBuilt();
if (!checkValidTime(t)) {
- throw new TimeRangeException();
+ throw new TimeRangeException(fSSID + " Time:" + t + ", Start:" + getStartTime() + ", End:" + getEndTime()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/* Reload the previous checkpoint */
/*******************************************************************************
- * Copyright (c) 2013, 2014 Ericsson
+ * Copyright (c) 2013, 2015 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
case NULL:
case STRING:
default:
- throw new StateValueTypeException();
+ throw new StateValueTypeException(ss.getSSID() + " Quark:" + quark + ", Type:" + value.getType()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
return max;
case NULL:
case STRING:
default:
- throw new StateValueTypeException();
+ throw new StateValueTypeException(ss.getSSID() + " Quark:" + quark + ", Type:" + value.getType()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
return min;