I wonder what is advantage of using InvalidArgumentException instead Exception?
Does it for increasing code readibility or there are another reasons for that?
public function setShortName($shortName){
$shortName = (string) $shortName;
if (strlen( $shortName ) == 2) {
$this->_shortName = (string) $shortName;
} else {
throw new InvalidArgumentException( "Ülke kısa ismi 2 karakterden oluşmak zorundadır", 115003 );
}
}
or
public function setShortName($shortName){
$shortName = (string) $shortName;
if (strlen( $shortName ) == 2) {
$this->_shortName = (string) $shortName;
} else {
throw new Exception( "Ülke kısa ismi 2 karakterden oluşmak zorundadır", 115003 );
}
}
It’s for better readability/debugging and for processing right block of code e.g. in try-catch block…
Note that exceptions have tree-based structure so handling depends on their order! (from lowest to root)
for more information: http://docs.oracle.com/javase/7/docs/api/java/lang/package-tree.html