001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.component.file;
018
019import org.apache.camel.RuntimeCamelException;
020
021/**
022 * Exception thrown in case of last file operation failed.
023 *
024 * @version 
025 */
026public class GenericFileOperationFailedException extends RuntimeCamelException {
027    private static final long serialVersionUID = -64176625836814418L;
028
029    private final int code;
030    private final String reason;
031
032    public GenericFileOperationFailedException(String message) {
033        super(message);
034        this.code = 0;
035        this.reason = null;
036    }
037
038    public GenericFileOperationFailedException(String message, Throwable cause) {
039        super(message, cause);
040        this.code = 0;
041        this.reason = null;
042    }
043
044    public GenericFileOperationFailedException(int code, String reason) {
045        super("File operation failed: " + reason + ". Code: " + code);
046        this.code = code;
047        this.reason = reason;
048    }
049
050    public GenericFileOperationFailedException(int code, String reason, Throwable cause) {
051        super("File operation failed: " + reason + ". Code: " + code, cause);
052        this.code = code;
053        this.reason = reason;
054    }
055
056    public GenericFileOperationFailedException(int code, String reason, String message) {
057        this(code, reason + " " + message);
058    }
059
060    public GenericFileOperationFailedException(int code, String reason, String message, Throwable cause) {
061        this(code, reason + " " + message, cause);
062    }
063
064    /**
065     * Return the file failure code (if any)
066     */
067    public int getCode() {
068        return code;
069    }
070
071    /**
072     * Return the file failure reason (if any)
073     */
074    public String getReason() {
075        return reason;
076    }
077}