Spaces:
Build error
Build error
File size: 2,480 Bytes
d46f4a3 |
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 |
package net.minecraft.server;
import com.google.common.collect.Lists;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
public class ChainedJsonException extends IOException {
private final List<ChainedJsonException.Entry> entries = Lists.newArrayList();
private final String message;
public ChainedJsonException(String p_135902_) {
this.entries.add(new ChainedJsonException.Entry());
this.message = p_135902_;
}
public ChainedJsonException(String p_135904_, Throwable p_135905_) {
super(p_135905_);
this.entries.add(new ChainedJsonException.Entry());
this.message = p_135904_;
}
public void prependJsonKey(String p_135909_) {
this.entries.get(0).addJsonKey(p_135909_);
}
public void setFilenameAndFlush(String p_135911_) {
this.entries.get(0).filename = p_135911_;
this.entries.add(0, new ChainedJsonException.Entry());
}
@Override
public String getMessage() {
return "Invalid " + this.entries.get(this.entries.size() - 1) + ": " + this.message;
}
public static ChainedJsonException forException(Exception p_135907_) {
if (p_135907_ instanceof ChainedJsonException) {
return (ChainedJsonException)p_135907_;
} else {
String s = p_135907_.getMessage();
if (p_135907_ instanceof FileNotFoundException) {
s = "File not found";
}
return new ChainedJsonException(s, p_135907_);
}
}
public static class Entry {
@Nullable
String filename;
private final List<String> jsonKeys = Lists.newArrayList();
Entry() {
}
void addJsonKey(String p_135919_) {
this.jsonKeys.add(0, p_135919_);
}
@Nullable
public String getFilename() {
return this.filename;
}
public String getJsonKeys() {
return StringUtils.join(this.jsonKeys, "->");
}
@Override
public String toString() {
if (this.filename != null) {
return this.jsonKeys.isEmpty() ? this.filename : this.filename + " " + this.getJsonKeys();
} else {
return this.jsonKeys.isEmpty() ? "(Unknown file)" : "(Unknown file) " + this.getJsonKeys();
}
}
}
} |