Pattern: Missing use of assert
with message
Issue: -
When assertions fail it's not always simple to understand why. Adding a message
to the assert
helps the developer to understand why the AssertionError
occurs.
Example of incorrect code:
f(a) {
assert(a != null);
}
class A {
A(a) : assert(a != null);
}
Example of correct code:
f(a) {
assert(a != null, 'a must not be null');
}
class A {
A(a) : assert(a != null, 'a must not be null');
}