我有这样的方法:
public function someMethod($param1 = null, $param2 = null)
{
...
if ($param1 == null &&...)
{
throw new Exception("Some parameter is wrong", 601);
}
}
因为我有异常代码,所以在异常消息中包含动态数据是一个好习惯吗?例如,异常可能如下所示:
throw new Exception("First parameter is wrong. You passed: {$param1}", 601);
您的意见是,动态消息是正常的还是我应该坚持使用固定文本来获取异常消息?