import com.opengamma.elsql.ElSql;
import com.opengamma.elsql.ElSqlConfig;
public class Test {
public static void main(String[] args) {
ElSql bundle = ElSql.of(ElSqlConfig.DEFAULT, Test.class);
bundle.getSql("test");
}
}
There is no matching .elsql resource and an exception will occur when when retrieving the 'test' fragment:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown fragment name: test
at com.opengamma.elsql.SqlFragments.getFragment(SqlFragments.java:172)
at com.opengamma.elsql.SqlFragments.getSql(SqlFragments.java:153)
at com.opengamma.elsql.ElSql.getSql(ElSql.java:141)
at Test.main(Test.java:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Process finished with exit code 1
My suggestion is to fail fast when there is no matching resource at all and provide a clear error message in that case. This will make debugging a little bit easier when you're just getting to know this library.
Consider the following code:
There is no matching
.elsql
resource and an exception will occur when when retrieving the 'test' fragment:My suggestion is to fail fast when there is no matching resource at all and provide a clear error message in that case. This will make debugging a little bit easier when you're just getting to know this library.