Fix warning_handler and pass error code to error_handler

Addresses issues #19 and #20.  Tests are still needed for both.