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 */ 017 package org.apache.camel.component.file; 018 019 import org.apache.camel.RuntimeCamelException; 020 021 /** 022 * Exception thrown in case of last file operation failed. 023 * 024 * @version $Revision: 737029 $ 025 */ 026 public class GenericFileOperationFailedException extends RuntimeCamelException { 027 private final int code; 028 private final String reason; 029 030 public GenericFileOperationFailedException(String message) { 031 super(message); 032 this.code = 0; 033 this.reason = null; 034 } 035 036 public GenericFileOperationFailedException(String message, Throwable cause) { 037 super(message, cause); 038 this.code = 0; 039 this.reason = null; 040 } 041 042 public GenericFileOperationFailedException(int code, String reason) { 043 super("File operation failed: " + reason + ". Code: " + code); 044 this.code = code; 045 this.reason = reason; 046 } 047 048 public GenericFileOperationFailedException(int code, String reason, Throwable cause) { 049 super("File operation failed: " + reason + ". Code: " + code, cause); 050 this.code = code; 051 this.reason = reason; 052 } 053 054 public GenericFileOperationFailedException(int code, String reason, String message) { 055 this(code, reason + " " + message); 056 } 057 058 public GenericFileOperationFailedException(int code, String reason, String message, Throwable cause) { 059 this(code, reason + " " + message, cause); 060 } 061 062 /** 063 * Return the file failure code (if any) 064 */ 065 public int getCode() { 066 return code; 067 } 068 069 /** 070 * Return the file failure reason (if any) 071 */ 072 public String getReason() { 073 return reason; 074 } 075 }