Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
PluginConfigurationDiagnoser |
|
| 3.0;3 |
1 | package org.apache.maven.usability; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.plugin.PluginConfigurationException; | |
23 | import org.apache.maven.plugin.PluginParameterException; | |
24 | import org.apache.maven.usability.diagnostics.DiagnosisUtils; | |
25 | import org.apache.maven.usability.diagnostics.ErrorDiagnoser; | |
26 | import org.codehaus.plexus.component.configurator.ComponentConfigurationException; | |
27 | ||
28 | 20 | public class PluginConfigurationDiagnoser |
29 | implements ErrorDiagnoser | |
30 | { | |
31 | public boolean canDiagnose( Throwable error ) | |
32 | { | |
33 | 4 | return DiagnosisUtils.containsInCausality( error, PluginConfigurationException.class ); |
34 | } | |
35 | ||
36 | public String diagnose( Throwable error ) | |
37 | { | |
38 | 9 | PluginConfigurationException pce = |
39 | (PluginConfigurationException) DiagnosisUtils.getFromCausality( error, PluginConfigurationException.class ); | |
40 | ||
41 | 9 | if ( pce instanceof PluginParameterException ) |
42 | { | |
43 | 8 | PluginParameterException exception = (PluginParameterException) pce; |
44 | ||
45 | 8 | return exception.buildDiagnosticMessage(); |
46 | } | |
47 | 1 | else if ( DiagnosisUtils.containsInCausality( pce, ComponentConfigurationException.class ) ) |
48 | { | |
49 | 1 | ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils.getFromCausality( |
50 | pce, ComponentConfigurationException.class ); | |
51 | ||
52 | 1 | return pce.buildConfigurationDiagnosticMessage( cce ); |
53 | } | |
54 | else | |
55 | { | |
56 | 0 | return pce.getMessage(); |
57 | } | |
58 | } | |
59 | } |