qdzo / ceylon-config Goto Github PK
View Code? Open in Web Editor NEWCeylon Library for managing app configuration.
License: Apache License 2.0
Ceylon Library for managing app configuration.
License: Apache License 2.0
Assertion errors in Ceylon indicate that something that should never happen in a correctly‐written program has happened; they are not meant to actually be caught. Catching them is not only bad practice, but it’s also inherently wrong by the definition of assertion errors.
Additionally, assertions are meant to check for developer input, and not user input. An uncaught assertion error implies that there is a bug in the program, and not that the user didn’t provide a necessary environment variable.
The correct thing to do would be to have your optional methods potentially return null
, and have your existence‐asserting methods check for their result and throw something that is not an AssertionError
in case they are null
so that it can be caught by the developer for them to display a proper error message.
That is, instead of writing the following:
shared String getString(Object key){
assert(exists val = get(key));
return val;
}
shared String? getStringOrNull(Object key){
try {
return getString(key);
} catch(AssertionError ae) {
return null;
}
}
it is, by the definition of AssertionError
, objectively more correct to write the following:
shared String? getStringOrNull(Object key) => this[key];
shared String getString(Object key)
{
if(exists string = getStringOrNull(key))
{
return(string);
}
else
{
throw(Something());
}
}
Perhaps more subjectively, I really don’t think these type‐unsafe non‐OrNull
methods are actually a good practice in Ceylon. Ideally you don’t want to give the user of your library the confidence that these values will exist, and instead, you should require them to actually act upon the possibility of them not existing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.