1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.transport;
11
12 import java.io.IOException;
13 import java.util.List;
14
15 import org.eclipse.jgit.errors.MissingObjectException;
16 import org.eclipse.jgit.transport.ReceiveCommand.Result;
17
18
19
20
21
22
23 public interface ReceiveCommandErrorHandler {
24
25
26
27
28
29
30
31
32 default void handleNewIdValidationException(ReceiveCommand cmd,
33 IOException e) {
34 cmd.setResult(Result.REJECTED_MISSING_OBJECT, cmd.getNewId().name());
35 }
36
37
38
39
40
41
42
43
44
45 default void handleOldIdValidationException(ReceiveCommand cmd,
46 IOException e) {
47 cmd.setResult(Result.REJECTED_MISSING_OBJECT, cmd.getOldId().name());
48 }
49
50
51
52
53
54
55
56
57
58 default void handleFastForwardCheckException(ReceiveCommand cmd,
59 IOException e) {
60 if (e instanceof MissingObjectException) {
61 cmd.setResult(Result.REJECTED_MISSING_OBJECT, e.getMessage());
62 } else {
63 cmd.setResult(Result.REJECTED_OTHER_REASON);
64 }
65 }
66
67
68
69
70
71
72
73
74
75 default void handleBatchRefUpdateException(List<ReceiveCommand> cmds,
76 IOException e) {
77 for (ReceiveCommand cmd : cmds) {
78 if (cmd.getResult() == Result.NOT_ATTEMPTED) {
79 cmd.reject(e);
80 }
81 }
82 }
83 }