There are two assertions. I think we want to revise the code to explicitly raise an ValueError type because the status is not valid for the current state. We wrap the error in expose() so that the API user can see the message. This might be the way to do this.
lp.registry.errors:
from lazr.restful.declarations import webservice_error
class TeamMembershipTransitionError(ValueError):
# HTTP Error: 'Not acceptable'
webservice_error(406)
lp.registry.model.teammembership:
from lazr.restful.error import expose
if self.status not in state_transition:
raise expose(TeamMembershipTransitionError( "Unknown status: %s" % self.status.name))
if status not in state_transition[self.status]:
raise expose(TeamMembershipTransitionError( "Bad state transition from %s to %s"
% (self.status.name, status.name))
There are two assertions. I think we want to revise the code to explicitly raise an ValueError type because the status is not valid for the current state. We wrap the error in expose() so that the API user can see the message. This might be the way to do this.
lp.registry.errors: declarations import webservice_error ransitionError( ValueError) : error(406)
from lazr.restful.
class TeamMembershipT
# HTTP Error: 'Not acceptable'
webservice_
lp.registry. model.teammembe rship:
from lazr.restful.error import expose
if self.status not in state_transition: TeamMembershipT ransitionError(
"Unknown status: %s" % self.status.name)) n[self. status] : TeamMembershipT ransitionError(
"Bad state transition from %s to %s"
raise expose(
if status not in state_transitio
raise expose(
% (self.status.name, status.name))