Skip to content

Commit ccc17b4

Browse files
committed
Fixed bug on check if controller is defined
1 parent 93b4e16 commit ccc17b4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

patterns/structural/mvc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ def __init__(self):
120120
self.routes: dict = {}
121121

122122
def register(self, path: str, controller_class: object, model_class: object, view_class: object) -> None:
123-
model_instance: object = model_class()
124-
view_instance: object = view_class()
123+
model_instance = model_class()
124+
view_instance = view_class()
125125
self.routes[path] = controller_class(model_instance, view_instance)
126126

127127
def resolve(self, path: str) -> Controller:
128128
if self.routes.get(path):
129-
controller_class: object = self.routes[path]
130-
return controller_class
129+
controller: Controller = self.routes[path]
130+
return controller
131131
else:
132-
return None
132+
raise KeyError(f"No controller registered for path '{path}'")
133133

134134

135135
def main():

0 commit comments

Comments
 (0)