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

Side by Side Diff: scheduler/appengine/ui/invocation.go

Issue 2993933002: scheduler ACLs: improve ACL-related error handling in UI and API. (Closed)
Patch Set: rebase Created 3 years, 4 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 | « scheduler/appengine/engine/engine.go ('k') | scheduler/appengine/ui/job.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 // Copyright 2015 The LUCI Authors. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 }() 49 }()
50 wg.Add(1) 50 wg.Add(1)
51 go func() { 51 go func() {
52 defer wg.Done() 52 defer wg.Done()
53 job, err2 = eng.GetVisibleJob(c.Context, projectID+"/"+jobName) 53 job, err2 = eng.GetVisibleJob(c.Context, projectID+"/"+jobName)
54 }() 54 }()
55 wg.Wait() 55 wg.Wait()
56 56
57 // panic on internal datastore errors to trigger HTTP 500. 57 // panic on internal datastore errors to trigger HTTP 500.
58 switch { 58 switch {
59 case err2 == engine.ErrNoSuchJob:
60 http.Error(c.Writer, "No such job or no permission", http.Status NotFound)
61 return
62 case err1 == engine.ErrNoSuchInvocation:
63 http.Error(c.Writer, "No such invocation", http.StatusNotFound)
64 return
59 case err1 != nil: 65 case err1 != nil:
60 panic(err1) 66 panic(err1)
61 case err2 != nil: 67 case err2 != nil:
62 panic(err2) 68 panic(err2)
63 case inv == nil:
64 http.Error(c.Writer, "No such invocation", http.StatusNotFound)
65 return
66 case job == nil:
67 http.Error(c.Writer, "No such job", http.StatusNotFound)
68 return
69 } 69 }
70 70
71 jobUI := makeJob(c.Context, job) 71 jobUI := makeJob(c.Context, job)
72 templates.MustRender(c.Context, c.Writer, "pages/invocation.html", map[s tring]interface{}{ 72 templates.MustRender(c.Context, c.Writer, "pages/invocation.html", map[s tring]interface{}{
73 "Job": jobUI, 73 "Job": jobUI,
74 "Inv": makeInvocation(jobUI, inv), 74 "Inv": makeInvocation(jobUI, inv),
75 }) 75 })
76 } 76 }
77 77
78 //////////////////////////////////////////////////////////////////////////////// 78 ////////////////////////////////////////////////////////////////////////////////
(...skipping 17 matching lines...) Expand all
96 switch err := cb(projectID+"/"+jobName, invIDAsInt); { 96 switch err := cb(projectID+"/"+jobName, invIDAsInt); {
97 case err == engine.ErrNoOwnerPermission: 97 case err == engine.ErrNoOwnerPermission:
98 http.Error(c.Writer, "Forbidden", 403) 98 http.Error(c.Writer, "Forbidden", 403)
99 return 99 return
100 case err != nil: 100 case err != nil:
101 panic(err) 101 panic(err)
102 default: 102 default:
103 http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s/%s", projectID, jobName, invID), http.StatusFound) 103 http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s/%s", projectID, jobName, invID), http.StatusFound)
104 } 104 }
105 } 105 }
OLDNEW
« no previous file with comments | « scheduler/appengine/engine/engine.go ('k') | scheduler/appengine/ui/job.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698