Cleaned up error handling by using abort() and abortWithMethod() from  Debug class.