我正在尝试为我的网站设置错误报告系统。目前,我正在为我的大部分代码添加try / catch块。对于我的catch块,我有一个包含的log.php文件。
我的catch块看起来像这样,
prepareForSegue:sender:
包含的log.php文件包含以下代码
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"GroupsHomeSegue"])
{
NSIndexPath* indexPath = [[someCollectionView indexPathsForSelectedItems] first];
if(indexPath != nil)
{
NSString* selectedDescription = arrayOfDescriptions[indexPath.item];
NSString* selectedImageName = arrayOfImages[indexPath.item];
// Get the destination view controller (the one that will be shown) from the segue and cast it to the appropriate type. Assuming this should be GroupsHomeViewController, but I'm not entirely sure that's correct since I can't see all your code
GroupsHomeViewController* groupsHomeViewController = segue.destinationViewController;
// Set the appropriate properties (Again, I'm guessing here since I can't see your code)
groupsHomeViewController.logoImage = [UIImage imageNamed: selectedImageName];
}
}
}
但是,当我的catch块被触发时,来自$ e的错误消息不会被传递。当我检查我最近的数据库条目时,我看到当PDO试图传入$ e时,其值为'null'
有没有人有任何想法?基本上我只想将所有错误记录到我的数据库中进行审核。感谢
答案 0 :(得分:-2)
尝试捕获通用Exception而不是PDOException。
参考这个答案: Catching multiple exception types in one catch block