All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.cocoon.ProcessingException Maven / Gradle / Ivy

Go to download

Module that contains dependencies to all modules normally needed for a basic Cocoon webapp. Cocoon blocks should normally depend on this modules, as the exact content of the more fine grained sitemap, pipeline and support modules is not stable yet. This module also contains some classes, configuration files and tests that we not have decided where to move yet.

There is a newer version: 2.3.0
Show newest version
/*
 * Copyright 1999-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.cocoon;

import java.util.List;

import org.apache.cocoon.util.location.LocatedException;
import org.apache.cocoon.util.location.LocatedRuntimeException;
import org.apache.cocoon.util.location.Location;
import org.apache.cocoon.util.location.MultiLocatable;

/**
 * This Exception is thrown every time there is a problem in processing
 * a request.
 *
 * @version $Id: ProcessingException.java 367031 2006-01-08 14:13:18Z antonio $
 */
public class ProcessingException extends LocatedException {
    
    /**
     * Construct a new ProcessingException instance.
     */
    public ProcessingException(String message) {
        super(message);
    }
    
    /**
     * Creates a new ProcessingException instance.
     *
     * @param ex an Exception value
     */
    public ProcessingException(Exception ex) {
        super(ex.getMessage(), ex);
    }
    
    /**
     * Construct a new ProcessingException that references
     * a parent Exception.
     */
    public ProcessingException(String message, Throwable t) {
        super(message, t);
    }
    
    /**
     * Construct a new ProcessingException that has an associated location.
     */
    public ProcessingException(String message, Location location) {
        super(message, location);
    }
    
    /**
     * Construct a new ProcessingException that has a parent exception
     * and an associated location.
     * 

* This constructor is protected to enforce the use of {@link #throwLocated(String, Throwable, Location)} * which limits exception nesting as far as possible. */ protected ProcessingException(String message, Throwable t, Location location) { super(message, t, location); } /** * Throw a located exception given an existing exception and the location where * this exception was catched. *

* If the exception is already a ProcessingException or a {@link LocatedRuntimeException}, * the location is added to the original exception's location chain and the original exception * is rethrown (description is ignored) to limit exception nesting. Otherwise, a new * ProcessingException is thrown, wrapping the original exception. *

* Note: this method returns an exception as a convenience if you want to keep the throw * semantics in the caller code, i.e. write
*   throw ProcessingException.throwLocated(...);
* instead of
*   ProcessingException.throwLocated(...);
*   return; * * @param message a message (can be null) * @param thr the original exception (can be null) * @param location the location (can be null) * @return a (fake) located exception * @throws ProcessingException or LocatedRuntimeException */ public static ProcessingException throwLocated(String message, Throwable thr, Location location) throws ProcessingException { if (thr instanceof ProcessingException) { ProcessingException pe = (ProcessingException)thr; pe.addLocation(location); throw pe; } else if (thr instanceof LocatedRuntimeException) { LocatedRuntimeException re = (LocatedRuntimeException)thr; re.addLocation(location); // Rethrow throw re; } throw new ProcessingException(message, thr, location); } /** * Throw a located exception given an existing exception and the locations where * this exception was catched. *

* If the exception is already a ProcessingException or a {@link LocatedRuntimeException}, * the locations are added to the original exception's location chain and the original exception * is rethrown (description is ignored) to limit exception nesting. Otherwise, a new * ProcessingException is thrown, wrapping the original exception. *

* Note: this method returns an exception as a convenience if you want to keep the throw * semantics in the caller code, i.e. write
*   throw ProcessingException.throwLocated(...);
* instead of
*   ProcessingException.throwLocated(...);
*   return; * * @param message a message (can be null) * @param thr the original exception (can be null) * @param locations the locations (can be null) * @return a (fake) located exception * @throws ProcessingException or LocatedRuntimeException */ public static ProcessingException throwLocated(String message, Throwable thr, List locations) throws ProcessingException { MultiLocatable multiloc; if (thr instanceof ProcessingException) { multiloc = (ProcessingException)thr; } else if (thr instanceof LocatedRuntimeException) { multiloc = (LocatedRuntimeException)thr; } else { multiloc = new ProcessingException(message, thr); } if (locations != null) { for (int i = 0; i < locations.size(); i++) { multiloc.addLocation((Location)locations.get(i)); } } if (multiloc instanceof LocatedRuntimeException) { throw (LocatedRuntimeException)multiloc; } else { throw (ProcessingException)multiloc; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy