Parse exceptions & open new window if the one used is full
This commit is contained in:
parent
b0d70f028f
commit
9926b68c26
@ -20,8 +20,8 @@ class TwoDA{
|
|||||||
string data[];
|
string data[];
|
||||||
|
|
||||||
auto results = matchAll(line, rgxField);
|
auto results = matchAll(line, rgxField);
|
||||||
if(results.hit is null)
|
if(results.empty)
|
||||||
throw new ParseException(filepath~":"~index.to!string~" Incorrect 2da line (not parseable)");
|
throw new ParseException("Could not parse fields in line: "~filepath~":"~index.to!string);
|
||||||
|
|
||||||
foreach(res ; results){
|
foreach(res ; results){
|
||||||
string s;
|
string s;
|
||||||
@ -31,9 +31,11 @@ class TwoDA{
|
|||||||
|
|
||||||
if(index==0){
|
if(index==0){
|
||||||
header = data;
|
header = data;
|
||||||
//writeln(header);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
if(data.length != header.length)
|
||||||
|
throw new ParseException("Incorrect number of fields: "~filepath~":"~index.to!string);
|
||||||
|
|
||||||
int nLine = data[0].to!int;
|
int nLine = data[0].to!int;
|
||||||
values[nLine] = data[1..$];
|
values[nLine] = data[1..$];
|
||||||
//writeln(values[nLine]);
|
//writeln(values[nLine]);
|
||||||
|
@ -340,9 +340,26 @@ class Window : MainWindow{
|
|||||||
|
|
||||||
|
|
||||||
void open(string file, ref TreeView tree){
|
void open(string file, ref TreeView tree){
|
||||||
|
writeln("Opening ",file);
|
||||||
|
TwoDA twoda;
|
||||||
|
try{
|
||||||
|
twoda = new TwoDA(file);
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
import gtk.MessageDialog;
|
||||||
|
auto md = new MessageDialog(this, GtkDialogFlags.MODAL, GtkMessageType.ERROR, GtkButtonsType.CLOSE, "Could not open 2da:\n"~e.msg, null);
|
||||||
|
md.run();
|
||||||
|
md.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto twoda = new TwoDA(file);
|
//Open in new window
|
||||||
|
if(openedFile!=null){
|
||||||
|
new Window(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Open in same window
|
||||||
openedFile = file;
|
openedFile = file;
|
||||||
header.setSubtitle(openedFile);
|
header.setSubtitle(openedFile);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user