<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* UnsupportedStrategyException.php
|
|
* Created by PhpStorm.
|
|
* Date: 2026/10/17
|
|
* Time: 09:40
|
|
* Author: qian.guo
|
|
* E-mail: yiyezhiqiutel@gmail.com
|
|
*/
|
|
|
|
namespace app\service\score\exception;
|
|
|
|
use app\BusinessException;
|
|
|
|
/**
|
|
* 评分策略不可用异常
|
|
* 设计说明:
|
|
* - strict 模式下配置了未注册的策略必须抛本异常,不允许静默回退到默认策略
|
|
* 静默回退会让配置写错却照常出结果,且落库的 strategy 字段与真实算法不符,事后无法复盘
|
|
* - 属于系统错误(配置问题),由 ExceptionHandle 统一出 500
|
|
*/
|
|
class UnsupportedStrategyException extends BusinessException
|
|
{
|
|
public function __construct($alias, $available = [])
|
|
{
|
|
$hint = '';
|
|
if (!empty($available)) {
|
|
$hint = ',可用:' . implode(', ', $available);
|
|
}
|
|
|
|
parent::__construct(
|
|
config('code.err.score_failed'),
|
|
'未注册的评分策略: ' . $alias . $hint
|
|
);
|
|
}
|
|
}
|