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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

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


Go to End


3 Posts   1748 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, 5523 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.