Errors

Changed handling of errors and also now handles 4xx errors.

Why using custom codes in error response? Sorry trying to grok.