    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;
    022
    023import cascading.CascadingException;
    024
    025/** FlowException instances are thrown on errors when executing a Flow. */
    026public class FlowException extends CascadingException
    027  {
    028  /** Field flowName */
    029  String flowName;
    030
    031  private static String createMessage( String flowName, String message )
    032    {
    033    if( flowName == null )
    034      return message;
    035
    036    return "[" + flowName + "] " + message;
    037    }
    038
    039  /** Constructor FlowException creates a new FlowException instance. */
    040  public FlowException()
    041    {
    042    }
    043
    044  /**
    045   * Constructor FlowException creates a new FlowException instance.
    046   *
    047   * @param message of type String
    048   */
    049  public FlowException( String message )
    050    {
    051    super( message );
    052    }
    053
    054  /**
    055   * Constructor FlowException creates a new FlowException instance.
    056   *
    057   * @param message   of type String
    058   * @param throwable of type Throwable
    059   */
    060  public FlowException( String message, Throwable throwable )
    061    {
    062    super( message, throwable );
    063    }
    064
    065  /**
    066   * Constructor FlowException creates a new FlowException instance.
    067   *
    068   * @param flowName  of type String
    069   * @param message   of type String
    070   * @param throwable of type Throwable
    071   */
    072  public FlowException( String flowName, String message, Throwable throwable )
    073    {
    074    super( createMessage( flowName, message ), throwable );
    075    this.flowName = flowName;
    076    }
    077
    078  /**
    079   * Constructor FlowException creates a new FlowException instance.
    080   *
    081   * @param flowName of type String
    082   * @param message  of type String
    083   */
    084  public FlowException( String flowName, String message )
    085    {
    086    super( createMessage( flowName, message ) );
    087    this.flowName = flowName;
    088    }
    089
    090  /**
    091   * Constructor FlowException creates a new FlowException instance.
    092   *
    093   * @param throwable of type Throwable
    094   */
    095  public FlowException( Throwable throwable )
    096    {
    097    super( throwable );
    098    }
    099
    100  /**
    101   * Method getFlowName returns the name of the parent {@link Flow} instance.
    102   *
    103   * @return the flowName (type String) of this FlowException object.
    104   */
    105  public String getFlowName()
    106    {
    107    return flowName;
    108    }
    109
    110  void setFlowName( String flowName )
    111    {
    112    this.flowName = flowName;
    113    }
    114  }