Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: ct/go/ctfe/chromium_builds/chromium_builds.go

Issue 1820863002: Update callers of httputils.ReportError to specify message (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Remove taskID Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ct/go/ctfe/chromium_perf/chromium_perf.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Handlers and types specific to Chromium builds. 2 Handlers and types specific to Chromium builds.
3 */ 3 */
4 4
5 package chromium_builds 5 package chromium_builds
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "bytes" 9 "bytes"
10 "database/sql" 10 "database/sql"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 func addTaskHandler(w http.ResponseWriter, r *http.Request) { 153 func addTaskHandler(w http.ResponseWriter, r *http.Request) {
154 task_common.AddTaskHandler(w, r, &AddTaskVars{}) 154 task_common.AddTaskHandler(w, r, &AddTaskVars{})
155 } 155 }
156 156
157 func getRevDataHandler(getLkgr func() (string, error), gitRepoUrl string, w http .ResponseWriter, r *http.Request) { 157 func getRevDataHandler(getLkgr func() (string, error), gitRepoUrl string, w http .ResponseWriter, r *http.Request) {
158 w.Header().Set("Content-Type", "application/json") 158 w.Header().Set("Content-Type", "application/json")
159 revString := r.FormValue("rev") 159 revString := r.FormValue("rev")
160 if revString == "" { 160 if revString == "" {
161 » » httputils.ReportError(w, r, fmt.Errorf("No revision specified"), "") 161 » » httputils.ReportError(w, r, nil, "No revision specified")
162 return 162 return
163 } 163 }
164 164
165 if strings.EqualFold(revString, "LKGR") { 165 if strings.EqualFold(revString, "LKGR") {
166 lkgr, err := getLkgr() 166 lkgr, err := getLkgr()
167 if err != nil { 167 if err != nil {
168 » » » httputils.ReportError(w, r, fmt.Errorf("Unable to retrie ve LKGR revision"), "") 168 » » » httputils.ReportError(w, r, nil, "Unable to retrieve LKG R revision")
169 } 169 }
170 glog.Infof("Retrieved LKGR commit hash: %s", lkgr) 170 glog.Infof("Retrieved LKGR commit hash: %s", lkgr)
171 revString = lkgr 171 revString = lkgr
172 } 172 }
173 commitUrl := gitRepoUrl + revString + "?format=JSON" 173 commitUrl := gitRepoUrl + revString + "?format=JSON"
174 glog.Infof("Reading revision detail from %s", commitUrl) 174 glog.Infof("Reading revision detail from %s", commitUrl)
175 resp, err := httpClient.Get(commitUrl) 175 resp, err := httpClient.Get(commitUrl)
176 if err != nil { 176 if err != nil {
177 httputils.ReportError(w, r, err, "Unable to retrieve revision de tail") 177 httputils.ReportError(w, r, err, "Unable to retrieve revision de tail")
178 return 178 return
179 } 179 }
180 defer skutil.Close(resp.Body) 180 defer skutil.Close(resp.Body)
181 if resp.StatusCode == 404 { 181 if resp.StatusCode == 404 {
182 // Return successful empty response, since the user could be typ ing. 182 // Return successful empty response, since the user could be typ ing.
183 if err := json.NewEncoder(w).Encode(map[string]interface{}{}); e rr != nil { 183 if err := json.NewEncoder(w).Encode(map[string]interface{}{}); e rr != nil {
184 httputils.ReportError(w, r, err, fmt.Sprintf("Failed to encode JSON: %v", err)) 184 httputils.ReportError(w, r, err, fmt.Sprintf("Failed to encode JSON: %v", err))
185 return 185 return
186 } 186 }
187 return 187 return
188 } 188 }
189 if resp.StatusCode != 200 { 189 if resp.StatusCode != 200 {
190 » » httputils.ReportError(w, r, fmt.Errorf("Unable to retrieve revis ion detail"), "") 190 » » httputils.ReportError(w, r, nil, "Unable to retrieve revision de tail")
191 return 191 return
192 } 192 }
193 // Remove junk in the first line. https://code.google.com/p/gitiles/issu es/detail?id=31 193 // Remove junk in the first line. https://code.google.com/p/gitiles/issu es/detail?id=31
194 bufBody := bufio.NewReader(resp.Body) 194 bufBody := bufio.NewReader(resp.Body)
195 if _, err = bufBody.ReadString('\n'); err != nil { 195 if _, err = bufBody.ReadString('\n'); err != nil {
196 httputils.ReportError(w, r, err, "Unable to retrieve revision de tail") 196 httputils.ReportError(w, r, err, "Unable to retrieve revision de tail")
197 return 197 return
198 } 198 }
199 if _, err = io.Copy(w, bufBody); err != nil { 199 if _, err = io.Copy(w, bufBody); err != nil {
200 httputils.ReportError(w, r, err, "Unable to retrieve revision de tail") 200 httputils.ReportError(w, r, err, "Unable to retrieve revision de tail")
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 r.HandleFunc("/"+ctfeutil.CHROMIUM_BUILD_URI, addTaskView).Methods("GET" ) 295 r.HandleFunc("/"+ctfeutil.CHROMIUM_BUILD_URI, addTaskView).Methods("GET" )
296 r.HandleFunc("/"+ctfeutil.CHROMIUM_BUILD_RUNS_URI, runsHistoryView).Meth ods("GET") 296 r.HandleFunc("/"+ctfeutil.CHROMIUM_BUILD_RUNS_URI, runsHistoryView).Meth ods("GET")
297 r.HandleFunc("/"+ctfeutil.CHROMIUM_REV_DATA_POST_URI, getChromiumRevData Handler).Methods("POST") 297 r.HandleFunc("/"+ctfeutil.CHROMIUM_REV_DATA_POST_URI, getChromiumRevData Handler).Methods("POST")
298 r.HandleFunc("/"+ctfeutil.SKIA_REV_DATA_POST_URI, getSkiaRevDataHandler) .Methods("POST") 298 r.HandleFunc("/"+ctfeutil.SKIA_REV_DATA_POST_URI, getSkiaRevDataHandler) .Methods("POST")
299 r.HandleFunc("/"+ctfeutil.ADD_CHROMIUM_BUILD_TASK_POST_URI, addTaskHandl er).Methods("POST") 299 r.HandleFunc("/"+ctfeutil.ADD_CHROMIUM_BUILD_TASK_POST_URI, addTaskHandl er).Methods("POST")
300 r.HandleFunc("/"+ctfeutil.GET_CHROMIUM_BUILD_TASKS_POST_URI, getTasksHan dler).Methods("POST") 300 r.HandleFunc("/"+ctfeutil.GET_CHROMIUM_BUILD_TASKS_POST_URI, getTasksHan dler).Methods("POST")
301 r.HandleFunc("/"+ctfeutil.UPDATE_CHROMIUM_BUILD_TASK_POST_URI, updateTas kHandler).Methods("POST") 301 r.HandleFunc("/"+ctfeutil.UPDATE_CHROMIUM_BUILD_TASK_POST_URI, updateTas kHandler).Methods("POST")
302 r.HandleFunc("/"+ctfeutil.DELETE_CHROMIUM_BUILD_TASK_POST_URI, deleteTas kHandler).Methods("POST") 302 r.HandleFunc("/"+ctfeutil.DELETE_CHROMIUM_BUILD_TASK_POST_URI, deleteTas kHandler).Methods("POST")
303 r.HandleFunc("/"+ctfeutil.REDO_CHROMIUM_BUILD_TASK_POST_URI, redoTaskHan dler).Methods("POST") 303 r.HandleFunc("/"+ctfeutil.REDO_CHROMIUM_BUILD_TASK_POST_URI, redoTaskHan dler).Methods("POST")
304 } 304 }
OLDNEW
« no previous file with comments | « no previous file | ct/go/ctfe/chromium_perf/chromium_perf.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698