implement API errors

fix PHPMD warning
implement API errors
add misc error