Hi abd,
you have written you custom code in wrong place. You should write you custom code where it is mentioned begin user code.
And for checking which error you are getting you can implement error handling and using log activity log the error.
Thanks,