    001/*
    002 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
    003 *
    004 * Project and contact information: http://www.cascading.org/
    005 *
    006 * This file is part of the Cascading project.
    007 *
    008 * Licensed under the Apache License, Version 2.0 (the "License");
    009 * you may not use this file except in compliance with the License.
    010 * You may obtain a copy of the License at
    011 *
    012 *     http://www.apache.org/licenses/LICENSE-2.0
    013 *
    014 * Unless required by applicable law or agreed to in writing, software
    015 * distributed under the License is distributed on an "AS IS" BASIS,
    016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    017 * See the License for the specific language governing permissions and
    018 * limitations under the License.
    019 */
    020
    021package cascading.flow.planner;
    022
    023import cascading.flow.FlowElement;
    024import cascading.flow.FlowException;
    025import cascading.pipe.Pipe;
    026import cascading.tap.Tap;
    027import cascading.util.TraceUtil;
    028
    029/**
    030 * Class ElementGraphException is thrown during rendering of a pipe assembly to
    031 * the Cascading internal "graph" representation.
    032 */
    033public class ElementGraphException extends FlowException
    034  {
    035  /** Field flowElement */
    036  private FlowElement flowElement;
    037
    038  /** Constructor ElementGraphException creates a new ElementGraphException instance. */
    039  public ElementGraphException()
    040    {
    041    }
    042
    043  public ElementGraphException( Pipe pipe, String message )
    044    {
    045    this( (FlowElement) pipe, TraceUtil.formatTrace( pipe, message ) );
    046    }
    047
    048  public ElementGraphException( Tap tap, String message )
    049    {
    050    this( (FlowElement) tap, TraceUtil.formatTrace( tap, message ) );
    051    }
    052
    053  /**
    054   * Constructor ElementGraphException creates a new ElementGraphException instance.
    055   *
    056   * @param flowElement of type FlowElement
    057   * @param message     of type String
    058   */
    059  public ElementGraphException( FlowElement flowElement, String message )
    060    {
    061    super( message );
    062    this.flowElement = flowElement;
    063    }
    064
    065  /**
    066   * Constructor ElementGraphException creates a new ElementGraphException instance.
    067   *
    068   * @param flowElement of type FlowElement
    069   * @param message     of type String
    070   * @param throwable   of type Throwable
    071   */
    072  public ElementGraphException( FlowElement flowElement, String message, Throwable throwable )
    073    {
    074    super( message, throwable );
    075    this.flowElement = flowElement;
    076    }
    077
    078  /**
    079   * Constructor ElementGraphException creates a new ElementGraphException instance.
    080   *
    081   * @param string of type String
    082   */
    083  public ElementGraphException( String string )
    084    {
    085    super( string );
    086    }
    087
    088  /**
    089   * Constructor ElementGraphException creates a new ElementGraphException instance.
    090   *
    091   * @param string    of type String
    092   * @param throwable of type Throwable
    093   */
    094  public ElementGraphException( String string, Throwable throwable )
    095    {
    096    super( string, throwable );
    097    }
    098
    099  /**
    100   * Constructor ElementGraphException creates a new ElementGraphException instance.
    101   *
    102   * @param throwable of type Throwable
    103   */
    104  public ElementGraphException( Throwable throwable )
    105    {
    106    super( throwable );
    107    }
    108
    109  /**
    110   * Method getFlowElement returns the flowElement of this ElementGraphException object.
    111   *
    112   * @return the flowElement (type FlowElement) of this ElementGraphException object.
    113   */
    114  public FlowElement getFlowElement()
    115    {
    116    return flowElement;
    117    }
    118
    119  Pipe getPipe()
    120    {
    121    if( flowElement instanceof Pipe )
    122      return (Pipe) flowElement;
    123
    124    return null;
    125    }
    126  }