|  | @@ -139,6 +139,7 @@ func (c *Client) CreateOrUpdateDashboard(contentJSON []byte) (err error) {
 | 
	
		
			
			| 139 | 139 |  		Overwrite: true,
 | 
	
		
			
			| 140 | 140 |  	}
 | 
	
		
			
			| 141 | 141 |  
 | 
	
		
			
			|  | 142 | +	// Generate the request body's JSON
 | 
	
		
			
			| 142 | 143 |  	reqBodyJSON, err := json.Marshal(reqBody)
 | 
	
		
			
			| 143 | 144 |  	if err != nil {
 | 
	
		
			
			| 144 | 145 |  		return
 | 
	
	
		
			
			|  | @@ -146,8 +147,11 @@ func (c *Client) CreateOrUpdateDashboard(contentJSON []byte) (err error) {
 | 
	
		
			
			| 146 | 147 |  
 | 
	
		
			
			| 147 | 148 |  	var httpError *httpUnkownError
 | 
	
		
			
			| 148 | 149 |  	var isHttpUnknownError bool
 | 
	
		
			
			|  | 150 | +	// Send the request
 | 
	
		
			
			| 149 | 151 |  	respBodyJSON, err := c.request("POST", "dashboards/db", reqBodyJSON)
 | 
	
		
			
			| 150 | 152 |  	if err != nil {
 | 
	
		
			
			|  | 153 | +		// Check the error against the httpUnkownError type in order to decide
 | 
	
		
			
			|  | 154 | +		// how to process the error
 | 
	
		
			
			| 151 | 155 |  		httpError, isHttpUnknownError = err.(*httpUnkownError)
 | 
	
		
			
			| 152 | 156 |  		// We process httpUnkownError errors below, after we decoded the body
 | 
	
		
			
			| 153 | 157 |  		if !isHttpUnknownError {
 | 
	
	
		
			
			|  | @@ -155,17 +159,19 @@ func (c *Client) CreateOrUpdateDashboard(contentJSON []byte) (err error) {
 | 
	
		
			
			| 155 | 159 |  		}
 | 
	
		
			
			| 156 | 160 |  	}
 | 
	
		
			
			| 157 | 161 |  
 | 
	
		
			
			|  | 162 | +	// Decode the response body
 | 
	
		
			
			| 158 | 163 |  	var respBody dbCreateOrUpdateResponse
 | 
	
		
			
			| 159 | 164 |  	if err = json.Unmarshal(respBodyJSON, &respBody); err != nil {
 | 
	
		
			
			| 160 | 165 |  		return
 | 
	
		
			
			| 161 | 166 |  	}
 | 
	
		
			
			| 162 | 167 |  
 | 
	
		
			
			| 163 |  | -	slug, err := helpers.GetDashboardSlug(contentJSON)
 | 
	
		
			
			| 164 |  | -	if err != nil {
 | 
	
		
			
			| 165 |  | -		return
 | 
	
		
			
			| 166 |  | -	}
 | 
	
		
			
			| 167 |  | -
 | 
	
		
			
			| 168 | 168 |  	if respBody.Status != "success" && isHttpUnknownError {
 | 
	
		
			
			|  | 169 | +		// Get the dashboard's slug for logging
 | 
	
		
			
			|  | 170 | +		slug, err := helpers.GetDashboardSlug(contentJSON)
 | 
	
		
			
			|  | 171 | +		if err != nil {
 | 
	
		
			
			|  | 172 | +			return
 | 
	
		
			
			|  | 173 | +		}
 | 
	
		
			
			|  | 174 | +
 | 
	
		
			
			| 169 | 175 |  		return fmt.Errorf(
 | 
	
		
			
			| 170 | 176 |  			"Failed to update dashboard %s (%d %s): %s",
 | 
	
		
			
			| 171 | 177 |  			slug, httpError.StatusCode, respBody.Status, respBody.Message,
 |