Add error loging
Pass $element parameter
Catch errors and send it into response
Use @inejct properties
Separate Logic, create abstract methods sendErrorResource() & sendResource()