Added more detailed error handling

namely being able to detect conflicts and bad requests