Skip to content

Commit

Permalink
Merge pull request #1306 from tardyp/t2960
Browse files Browse the repository at this point in the history
buildbot.service: better handle error

Fixes ticket:2960
  • Loading branch information
Mikhail Sobolev committed Oct 30, 2014
2 parents ed366c5 + 6b8af38 commit 7e049a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
18 changes: 11 additions & 7 deletions www/base/src/app/builders/build/build.controller.coffee
Expand Up @@ -5,6 +5,8 @@ class Build extends Controller

buildbotService.bindHierarchy($scope, $stateParams, ['builders', 'builds'])
.then ([builder, build]) ->
if not build.number? and buildnumber > 1
$state.go('build', builder:builderid, build:buildnumber - 1)
breadcrumb = [
caption: "Builders"
sref: "builders"
Expand All @@ -21,11 +23,16 @@ class Build extends Controller
sref: "build({build:#{buildnumber - 1}})"

glBreadcrumbService.setBreadcrumb(breadcrumb)
buildbotService.one('builders', builderid).one('builds', buildnumber + 1).bind($scope, dest_key:"nextbuild").then ->
breadcrumb.push
caption: ''
sref: "build({build:#{buildnumber + 1}})"

unwatch = $scope.$watch 'nextbuild.number', (n, o) ->
if n?
breadcrumb.push
caption: ''
sref: "build({build:#{buildnumber + 1}})"
glBreadcrumbService.setBreadcrumb(breadcrumb)
unwatch()

buildbotService.one('builders', builderid).one('builds', buildnumber + 1).bind($scope, dest_key:"nextbuild")
buildbotService.one("buildslaves", build.buildslaveid).bind($scope)
buildbotService.one("buildrequests", build.buildrequestid)
.bind($scope).then (buildrequest) ->
Expand All @@ -35,6 +42,3 @@ class Build extends Controller
recentStorage.addBuild
link: "#/builders/#{$scope.builder.builderid}/build/#{$scope.build.number}"
caption: "#{$scope.builder.name} / #{$scope.build.number}"
, ->
if buildnumber > 1
$state.go('build', builder:builderid, build:buildnumber - 1)
19 changes: 17 additions & 2 deletions www/base/src/app/common/services/buildbot/buildbot.service.coffee
Expand Up @@ -79,7 +79,7 @@ class BuildbotService extends Factory
e[k] = v
return
if not _.isArray(l)
debugger
throw Error("Collection value is not an array!")
value["id"] = value[idkey]
value["_raw_data"] = angular.copy(value)
# restangularize the object before putting it in
Expand All @@ -106,6 +106,21 @@ class BuildbotService extends Factory
elem.on("*", onUpdate).then (unsub) ->
events.push(unsub)
return res
, (res) -> # got error
elem.value = null
if res.status == 404
# It does not exist yet. That might be the case later
# we still 'define' it will all attributes 'undefined'
# and register to update events
# this allows controllers to watch until the value is defined
elem.value = {}
elem.on("*", onUpdate).then (unsub) ->
events.push(unsub)
return elem.value
# if not 404, we say it is unbound, to maybe retry later, and reject the promise
else
bound = false
return $q.reject(res)
elem.value = p
return p

Expand Down Expand Up @@ -181,4 +196,4 @@ class BuildbotService extends Factory
l.push(r.bind($scope))
return $q.all(l)
addSomeAndMemoize(self)
return self
return self

0 comments on commit 7e049a9

Please sign in to comment.