mirror of
				https://github.com/matrix-org/gomatrix
				synced 2025-11-04 06:18:05 +00:00 
			
		
		
		
	Log response body when content upload fails
This commit is contained in:
		
							parent
							
								
									812dcb5515
								
							
						
					
					
						commit
						3c91bb314d
					
				
					 1 changed files with 10 additions and 1 deletions
				
			
		
							
								
								
									
										11
									
								
								client.go
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								client.go
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -9,6 +9,7 @@ import (
 | 
			
		|||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"path"
 | 
			
		||||
| 
						 | 
				
			
			@ -556,8 +557,16 @@ func (cli *Client) UploadToContentRepo(content io.Reader, contentType string, co
 | 
			
		|||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if res.StatusCode != 200 {
 | 
			
		||||
		contents, err := ioutil.ReadAll(res.Body)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, HTTPError{
 | 
			
		||||
				Message: "Upload request failed - Failed to read response body: " + err.Error(),
 | 
			
		||||
				Code:    res.StatusCode,
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		log.Printf("Upload request failed: %s", string(contents))
 | 
			
		||||
		return nil, HTTPError{
 | 
			
		||||
			Message: "Upload request failed",
 | 
			
		||||
			Message: "Upload request failed" + string(contents),
 | 
			
		||||
			Code:    res.StatusCode,
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue