-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathTribbleException.java
More file actions
153 lines (133 loc) · 5.54 KB
/
TribbleException.java
File metadata and controls
153 lines (133 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* The MIT License
*
* Copyright (c) 2013 The Broad Institute
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package htsjdk.tribble;
/**
* @author Aaron
*
* The base Tribble exception; this allows external libraries to catch any exception Tribble generates
*
*/
public class TribbleException extends RuntimeException {
// what file or input source we are working from
String source;
public TribbleException(String msg) {
super(msg);
}
public TribbleException(String message, Throwable throwable) {
super(message, throwable);
}
/**
* set the source for the file; where we got lines from
* @param source the source location, usually a file though it could be a http link or other source
*/
public void setSource(String source) {
this.source = source;
}
/**
* override the default message with ours, which attaches the source file in question
* @return a string with our internal error, along with the causitive source file (or other input source)
*/
@Override
public String getMessage() {
String ret = super.getMessage();
if ( source != null )
ret = ret + ", for input source: " + source;
return ret;
}
// //////////////////////////////////////////////////////////////////////
// other more specific exceptions generated in Tribble
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Codec exception
// //////////////////////////////////////////////////////////////////////
// if the line to decode is incorrect
public static class InvalidDecodeLine extends TribbleException {
public InvalidDecodeLine(String message, String line) { super (message + ", line = " + line); }
public InvalidDecodeLine(String message, int lineNo) { super (message + ", at line number " + lineNo); }
}
public static class InvalidHeader extends TribbleException {
public InvalidHeader(String message) { super ("Your input file has a malformed header: " + message); }
}
// capture other internal codec exceptions
public static class InternalCodecException extends TribbleException {
public InternalCodecException(String message) { super (message); }
}
public static class VersionValidationFailure extends TribbleException {
public VersionValidationFailure(final String message) {
super(String.format("Version validation failure: %s", message));
}
}
// //////////////////////////////////////////////////////////////////////
// Index exceptions
// //////////////////////////////////////////////////////////////////////
public static class UnableToCreateCorrectIndexType extends TribbleException {
public UnableToCreateCorrectIndexType(String message, Exception e) {
super(message,e);
}
public UnableToCreateCorrectIndexType(String message) {
super(message);
}
}
// //////////////////////////////////////////////////////////////////////
// Source exceptions
// //////////////////////////////////////////////////////////////////////
public static class FeatureFileDoesntExist extends TribbleException {
public FeatureFileDoesntExist(String message, String file) {
super(message);
setSource(file);
}
}
public static class MalformedFeatureFile extends TribbleException {
public MalformedFeatureFile(String message, String f, Exception e) {
super(message,e);
setSource(f);
}
public MalformedFeatureFile(String message, String f) {
super(message);
setSource(f);
}
}
public static class UnableToReadIndexFile extends TribbleException {
public UnableToReadIndexFile(String message, String f, Exception e) {
super(message,e);
setSource(f);
}
}
public static class CorruptedIndexFile extends TribbleException {
public CorruptedIndexFile(String message, String f, Exception e) {
super(message,e);
setSource(f);
}
}
public static class TabixReaderFailure extends TribbleException {
public TabixReaderFailure(String message, String f, Exception e) {
super(message,e);
setSource(f);
}
public TabixReaderFailure(String message, String f) {
super(message);
setSource(f);
}
}
}