abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyboardData.java
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/juloo.keyboard2/KeyboardData.java')
-rw-r--r--srcs/juloo.keyboard2/KeyboardData.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java
index 9326ad8..989c5f6 100644
--- a/srcs/juloo.keyboard2/KeyboardData.java
+++ b/srcs/juloo.keyboard2/KeyboardData.java
@@ -221,7 +221,7 @@ class KeyboardData
private static KeyboardData parse_keyboard(XmlPullParser parser) throws Exception
{
if (!expect_tag(parser, "keyboard"))
- throw new Exception("Empty layout file");
+ throw error(parser, "Expected tag <keyboard>");
boolean add_bottom_row = attribute_bool(parser, "bottom_row", true);
float specified_kw = attribute_float(parser, "width", 0f);
String script = parser.getAttributeValue(null, "script");
@@ -238,7 +238,7 @@ class KeyboardData
modmap = Modmap.parse(parser);
break;
default:
- throw new Exception("Unknown tag: " + parser.getName());
+ throw error(parser, "Expecting tag <row>, got <" + parser.getName() + ">");
}
}
float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows);
@@ -258,7 +258,7 @@ class KeyboardData
private static Row parse_row(XmlPullParser parser) throws Exception
{
if (!expect_tag(parser, "row"))
- throw new Exception("Failed to parse row");
+ throw error(parser, "Expected tag <row>");
return Row.parse(parser);
}
@@ -604,7 +604,8 @@ class KeyboardData
if (!next_tag(parser))
return false;
if (!parser.getName().equals(name))
- throw new Exception("Unknown tag: " + parser.getName());
+ throw error(parser, "Expecting tag <" + name + ">, got <" +
+ parser.getName() + ">");
return true;
}
@@ -623,4 +624,10 @@ class KeyboardData
return default_val;
return Float.parseFloat(val);
}
+
+ /** Construct a parsing error. */
+ private static Exception error(XmlPullParser parser, String message)
+ {
+ return new Exception(message + " " + parser.getPositionDescription());
+ }
}