change warnings to PHP exceptions