001    package org.apache.archiva.rest.api.services;
002    /*
003     * Licensed to the Apache Software Foundation (ASF) under one
004     * or more contributor license agreements.  See the NOTICE file
005     * distributed with this work for additional information
006     * regarding copyright ownership.  The ASF licenses this file
007     * to you under the Apache License, Version 2.0 (the
008     * "License"); you may not use this file except in compliance
009     * with the License.  You may obtain a copy of the License at
010     *
011     *   http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing,
014     * software distributed under the License is distributed on an
015     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016     * KIND, either express or implied.  See the License for the
017     * specific language governing permissions and limitations
018     * under the License.
019     */
020    
021    /**
022     * @author Olivier Lamy
023     * @since 1.4-M1
024     */
025    public class ArchivaRestServiceException
026        extends Exception
027    {
028    
029        private int httpErrorCode = 500;
030    
031        private String errorKey;
032    
033        /**
034         * can return the field name of bean with issue
035         * can be <code>null</code>
036         *
037         * @since 1.4-M3
038         */
039        private String fieldName;
040    
041    
042        public ArchivaRestServiceException( String message, Throwable t )
043        {
044            super( message, t );
045        }
046    
047        public ArchivaRestServiceException( String message, String fieldName, Throwable t )
048        {
049            this( message, t );
050            this.fieldName = fieldName;
051        }
052    
053        public ArchivaRestServiceException( String s, int httpErrorCode, Throwable t )
054        {
055            super( s, t );
056            this.httpErrorCode = httpErrorCode;
057        }
058    
059        public ArchivaRestServiceException( String s, int httpErrorCode, String fieldName, Throwable t )
060        {
061            this( s, httpErrorCode, t );
062            this.fieldName = fieldName;
063        }
064    
065        public int getHttpErrorCode()
066        {
067            return httpErrorCode;
068        }
069    
070        public void setHttpErrorCode( int httpErrorCode )
071        {
072            this.httpErrorCode = httpErrorCode;
073        }
074    
075        public String getErrorKey()
076        {
077            return errorKey;
078        }
079    
080        public void setErrorKey( String errorKey )
081        {
082            this.errorKey = errorKey;
083        }
084    
085        public String getFieldName()
086        {
087            return fieldName;
088        }
089    
090        public void setFieldName( String fieldName )
091        {
092            this.fieldName = fieldName;
093        }
094    }