better error-handling: json-formatted error messages