1
2
3
4
5
6
7
8
9
10
11
12
13 package org.eclipse.jgit.errors;
14
15 import static java.nio.charset.StandardCharsets.US_ASCII;
16
17 import java.text.MessageFormat;
18
19 import org.eclipse.jgit.internal.JGitText;
20
21
22
23
24 public class InvalidObjectIdException extends IllegalArgumentException {
25 private static final long serialVersionUID = 1L;
26
27
28
29
30
31
32
33
34 public InvalidObjectIdException(byte[] bytes, int offset, int length) {
35 super(msg(bytes, offset, length));
36 }
37
38
39
40
41
42
43
44
45 public InvalidObjectIdException(String id) {
46 super(MessageFormat.format(JGitText.get().invalidId, id));
47 }
48
49 private static String msg(byte[] bytes, int offset, int length) {
50 try {
51 return MessageFormat.format(
52 JGitText.get().invalidId,
53 new String(bytes, offset, length, US_ASCII));
54 } catch (StringIndexOutOfBoundsException e) {
55 return JGitText.get().invalidId0;
56 }
57 }
58 }