terraform-provider-bigip
                                
                                
                                
                                    terraform-provider-bigip copied to clipboard
                            
                            
                            
                        Error handling and log messages is not unified/aligned
I've been going over our error handling practices and some of the log messages and I think we need to have some alignment, especially with Terraform's best practices:
- 
Error checking should be done on aggregate types only (schema.TypeList, schema.TypeSet, and schema.TypeMap) reference: https://www.terraform.io/docs/extend/best-practices/detecting-drift.html#error-checking-aggregate-types
 - 
In case of error in a Set operations or any other action we need to use
return fmt.Errorf()method with a short description of the error that occurred, affected resource and the error content, for example: 
return fmt.Errorf("error getting resource %s: %v", d.Id(), err)
Currently, we use log.Printf() and return err which is not a very good way to handle this, since the log message is suppressed and the err returned lacks context.
- Logging of debug messages we wish to add throughout the code, should use 
log.Printf()(if formatting is required) orlog.Println()(if there's no formatting) and be tagged as[DEBUG], but this should not be used in error contexts. 
I will try to work on a PR to align with these practices.
/cc @scshitole