Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

how to stop errors displaying on screen and switch to not found . Bad class to singleton() - Business5Area


Reply


3 Posts   1063 Views

Avatar
vancouverWill

Community Member, 121 Posts

17 September 2009 at 9:10am

Edited: 17/09/2009 9:15am

I need to know how to stop errors displaying on screen and switch to not found when calling a database with

$this->projectCategory = DataObject::get_one($id, "`$id`.`URLSegment`='$secondId'"

. Bad class to singleton() - Business5Area

edit:

sorry I posted by accident before finialising the post.
anyway the problem I have is I am ge3tting the class from the URL so if someone miss types the URL they don't get a page not found they get a silverstripe error. I have attempted try->catch and this left the same problem. Is there any silverstripe way to catch an error like this and send to a safe page instead of displaying all the errors on the screen. btw if I set the site to live version I still get the blue screen just with the non descript error.

Hope this is a simple thing I a missing out on.

Avatar
Willr

Forum Moderator, 5513 Posts

17 September 2009 at 6:32pm

you can use class_exists to test if a string is a valid classname. class_exists($id)

Avatar
vancouverWill

Community Member, 121 Posts

18 September 2009 at 9:32am

Thanks

Once again you saved my life.