Skip to content

More specific exception for cases when there are no files to archive #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.codehaus.plexus.archiver.ArchiveEntry;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.ResourceIterator;
import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils;
import org.codehaus.plexus.archiver.util.ResourceUtils;
import org.codehaus.plexus.components.io.attributes.SymlinkUtils;
Expand Down Expand Up @@ -53,7 +54,7 @@ public void execute()
final ResourceIterator iter = getResources();
if ( !iter.hasNext() )
{
throw new ArchiverException( "You must set at least one file." );
throw new EmptyArchiveException( "You must set at least one file." );
}

final File destDirectory = getDestFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2004 The Apache Software Foundation
* <p/>
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.codehaus.plexus.archiver.exceptions;

import org.codehaus.plexus.archiver.ArchiverException;

public class EmptyArchiveException
extends ArchiverException
{

public EmptyArchiveException(String message )
{
super( message );
}

public EmptyArchiveException(String message, Throwable cause )
{
super( message, cause );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.codehaus.plexus.archiver.ArchiveEntry;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.ResourceIterator;
import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
import org.codehaus.plexus.archiver.util.ResourceUtils;
import org.codehaus.plexus.archiver.util.Streams;
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
Expand Down Expand Up @@ -110,7 +111,7 @@ protected void execute()
ResourceIterator iter = getResources();
if ( !iter.hasNext() )
{
throw new ArchiverException( "You must set at least one file." );
throw new EmptyArchiveException( "You must set at least one file." );
}

File tarFile = getDestFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.ResourceIterator;
import org.codehaus.plexus.archiver.UnixStat;
import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
import org.codehaus.plexus.archiver.util.ResourceUtils;
import org.codehaus.plexus.components.io.functions.SymlinkDestinationSupplier;
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
Expand Down Expand Up @@ -254,7 +255,7 @@ private void createArchiveMain()
ResourceIterator iter = getResources();
if ( !iter.hasNext() && !hasVirtualFiles() )
{
throw new ArchiverException( "You must set at least one file." );
throw new EmptyArchiveException( "You must set at least one file." );
}

zipFile = getDestFile();
Expand Down