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   1060 Views

Avatar
vancouverWill

17 September 2009 at 9:10am (Last edited: 17 September 2009 9:15am), Community Member, 121 Posts

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

17 September 2009 at 6:32pm Forum Moderator, 5511 Posts

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

Avatar
vancouverWill

18 September 2009 at 9:32am Community Member, 121 Posts

Thanks

Once again you saved my life.