package server;
import java.util.Locale;
public class InternalHanabiError extends RuntimeException {
private static final long serialVersionUID = -4200899696265442750L;
public InternalHanabiError() { }
public InternalHanabiError(String msg) { super(msg); }
public InternalHanabiError(String msg, Throwable cause) { super(msg, cause); }
public InternalHanabiError(Throwable cause) { super(cause); }
private String[] msgs;
public String[] getMessages() { return msgs; }
/**
* Does not deep-copy msgs. If msgs is null, getMessage will return the String passed in to InternalHanabiError(String) or InternalHanabiError(String, Throwable), if any; if msgs is 0-length, String[]{ "" } is used.
*/
public void setMessages(String[] msgs) {
if(msgs != null && msgs.length < 1) msgs = new String[]{ "" };
this.msgs = msgs;
}
/** @param msgs Array containing descriptions with decreasing detail level, as information for a bug report dialogue. The array is not deep-copied. */
public InternalHanabiError(String[] msgs) {
setMessages(msgs);
}
/** See InternalHanabiError(String[]). */
public InternalHanabiError(String[] msgs, Throwable cause) {
this(cause);
setMessages(msgs);
}
@Override
public String getMessage() {
if(msgs == null) return super.getMessage();
return msgs[0];
}
}
class Msgs {
private static class defaultMsgs {
static final String[] toJsonErr = new String[]{
"Internal error while serializing object to JSON.",
"Please submit a bug report."
};
static final String sleepInterrupted = "Ignored Interrupted exception while trying to sleep.";
}
private static Locale locale;
static void init(Locale l) {
locale = l;
}
static String[] toJsonErr() {
if(locale == null) /* ... */ ; // TODO !
return defaultMsgs.toJsonErr;
}
static String sleepInterrupted() {
if(locale == null) /* ... */ ; // TODO !
return defaultMsgs.sleepInterrupted;
}
}