1 | |
package com.aragost.javahg; |
2 | |
|
3 | |
import com.aragost.javahg.internals.AbstractCommand; |
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
public class UnknownCommandException extends RuntimeException { |
15 | |
|
16 | |
private static final long serialVersionUID = 1L; |
17 | |
|
18 | |
|
19 | |
|
20 | |
private final AbstractCommand command; |
21 | |
|
22 | |
public UnknownCommandException(AbstractCommand cmd) { |
23 | 1 | super(createMessage(cmd)); |
24 | 1 | this.command = cmd; |
25 | 1 | } |
26 | |
|
27 | |
private static String createMessage(AbstractCommand cmd) { |
28 | 1 | HgVersion hgVersion = getHgVersion(cmd); |
29 | 1 | return "Mercurial command '" + cmd.getCommandName() + "' is not supported by Mercurial version: " |
30 | |
+ hgVersion.getVersionString(); |
31 | |
} |
32 | |
|
33 | |
private static HgVersion getHgVersion(AbstractCommand cmd) { |
34 | 1 | HgVersion hgVersion = HgVersion.unknown(); |
35 | |
try { |
36 | 1 | hgVersion = cmd.getRepository().getHgVersion(); |
37 | 0 | } catch (RuntimeException e) { |
38 | |
|
39 | |
|
40 | 1 | } |
41 | 1 | return hgVersion; |
42 | |
} |
43 | |
|
44 | |
public AbstractCommand getCommand() { |
45 | 1 | return command; |
46 | |
} |
47 | |
|
48 | |
} |