I'm creating some re-usable functions, and right now I have error handling setup like this:
<?php
...
public function insertAfter( $index, $objects )
{
if ( ! is_int( $index ) ) {
trigger_error( 'Cursor::insertAfter() expects parameter 1 to be integer, ' . gettype( $index ) . ' given', E_USER_WARNING );
} else {
// Do my regular code
}
return $this;
}
...
I tried setting it up to work just like PHP would handle an error. Is this an appropriate way to do things?