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
|
use core:lang;
/**
* Thrown when an invalid table name is encountered.
*/
class NoSuchTable extends SyntaxError {
init(SrcPos pos, Str name) {
init(pos, "No table named ${name} is known.") {}
}
}
/**
* Thrown when we don't find a column.
*/
class NoSuchColumn extends SyntaxError {
init(SrcPos pos, Str col, Str table) {
init(pos, "No column named ${col} in ${table}.") {}
}
}
/**
* Thrown on dupliate alias declaration.
*/
class DuplicateAlias extends SyntaxError {
init(SrcPos pos, Str alias) {
init(pos, "The alias ${alias} is already defined in this query.") {}
}
}
/**
* Error in the database schema.
*/
class SchemaError extends SQLError {
init(Str message, Table expected, Schema actual) {
init(message) {
expected = expected;
actual = actual;
}
}
private Table expected;
private Schema actual;
void message(StrBuf out) : override {
super:message(out);
out << "\nExpected these columns in table " << actual.name << "\n";
out.indent();
for (c in expected.columns)
out << c << "\n";
out.dedent();
out << "But got the following columns:\n";
out.indent();
for (Nat i = 0; i < actual.count; i++) {
out << actual[i];
out << "\n";
}
out.dedent();
}
}
|