1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.resolution
;
13 import org
.eclipse
.aether
.RepositoryException
;
16 * Thrown in case of an unreadable or unresolvable artifact descriptor.
18 public class ArtifactDescriptorException
19 extends RepositoryException
22 private final transient ArtifactDescriptorResult result
;
25 * Creates a new exception with the specified result.
27 * @param result The descriptor result at the point the exception occurred, may be {@code null}.
29 public ArtifactDescriptorException( ArtifactDescriptorResult result
)
31 super( "Failed to read artifact descriptor"
32 + ( result
!= null ?
" for " + result
.getRequest().getArtifact() : "" ), getCause( result
) );
37 * Creates a new exception with the specified result and detail message.
39 * @param result The descriptor result at the point the exception occurred, may be {@code null}.
40 * @param message The detail message, may be {@code null}.
42 public ArtifactDescriptorException( ArtifactDescriptorResult result
, String message
)
44 super( message
, getCause( result
) );
49 * Creates a new exception with the specified result, detail message and cause.
51 * @param result The descriptor result at the point the exception occurred, may be {@code null}.
52 * @param message The detail message, may be {@code null}.
53 * @param cause The exception that caused this one, may be {@code null}.
55 public ArtifactDescriptorException( ArtifactDescriptorResult result
, String message
, Throwable cause
)
57 super( message
, cause
);
62 * Gets the descriptor result at the point the exception occurred. Despite being incomplete, callers might want to
63 * use this result to fail gracefully and continue their operation with whatever interim data has been gathered.
65 * @return The descriptor result or {@code null} if unknown.
67 public ArtifactDescriptorResult
getResult()
72 private static Throwable
getCause( ArtifactDescriptorResult result
)
74 Throwable cause
= null;
75 if ( result
!= null && !result
.getExceptions().isEmpty() )
77 cause
= result
.getExceptions().get( 0 );