Mercurial > hg4j
comparison src/org/tmatesoft/hg/util/Status.java @ 360:150500515714
Report non-critical errors during status operation to handler/inspector
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 08 Dec 2011 22:19:27 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
359:1d9bcab9c50f | 360:150500515714 |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.util; | |
18 | |
19 import org.tmatesoft.hg.internal.Experimental; | |
20 | |
21 /** | |
22 * Success/failure descriptor. When exception is too much. | |
23 * | |
24 * @author Artem Tikhomirov | |
25 * @author TMate Software Ltd. | |
26 */ | |
27 @Experimental(reason="Accidental use, does not justify dedicated class, perhaps.") | |
28 public class Status { | |
29 // XXX perhaps private enum and factory method createError() and createOk()? | |
30 public enum Kind { | |
31 OK, ERROR; | |
32 } | |
33 | |
34 private final Kind kind; | |
35 private final String message; | |
36 private final Exception error; | |
37 | |
38 public Status(Kind k, String msg) { | |
39 this(k, msg, null); | |
40 } | |
41 | |
42 public Status(Kind k, String msg, Exception err) { | |
43 kind = k; | |
44 message = msg; | |
45 error = err; | |
46 } | |
47 | |
48 public boolean isOk() { | |
49 return kind == Kind.OK; | |
50 } | |
51 | |
52 public Kind getKind() { | |
53 return kind; | |
54 } | |
55 | |
56 public String getMessage() { | |
57 return message; | |
58 } | |
59 | |
60 public Exception getException() { | |
61 return error; | |
62 } | |
63 } |