Sometimes (a lot of the time...) it can be very hard to tell why your Magento 2 site is not working when you're writing some custom code etc etc...
Magento 2 can be a bit enigmatic when having errors...
The cli command bin/magento setup:di:compile can sometimes give you good info on why something is not working.