Move error handling stuff to errors.go

Move all API error handling code (API error types and the
extractAPIErrors function) to new file errors.go

Add two new error types: APIError and APIWarning, which represent
generic API errors and warnings, respectively.

Add table-driven test for extractAPIErrors function.