Skip to content

资源找不到,在非调试模式下,应该返回空或null,而不是异常 #89

@jorry2008

Description

@jorry2008

Aliyun-oss-storage/src/AliOssAdapter.php
为什么在这里获取url,不存在时直接就异常!

/**
* @param $path
*
* @return string
*/
public function getUrl( $path )
{
if (!$this->has($path)) throw new FileNotFoundException($filePath.' not found');
return ( $this->ssl ? 'https://' : 'http://' ) . ( $this->isCname ? ( $this->cdnDomain == '' ? $this->endPoint : $this->cdnDomain ) : $this->bucket . '.' . $this->endPoint ) . '/' . ltrim($path, '/');
}

路径无法找到,仅仅是资源不存在而已,并不是程序无法进行下去,返回空或者null都可以,这里返回异常导致整个程序奔溃。
这里没有结合laravel的环境,调试模式下异常抛出会不会更好,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions