Exceptions
All public transfer failures extend Aria2Exception, which itself extends RuntimeException. Catch the base type when you want every package error, or a subclass when you care about the cause.
use Dasundev\LaravelAria2\Exceptions\Aria2Exception;use Dasundev\LaravelAria2\Exceptions\TransferCancelledException;use Dasundev\LaravelAria2\Exceptions\TransferFailedException;use Dasundev\LaravelAria2\Facades\Aria2; try { Aria2::url($url)->dir($directory)->download();} catch (TransferCancelledException $exception) { // User asked to stop.} catch (TransferFailedException $exception) { // aria2 failed, or the destination was missing.} catch (Aria2Exception $exception) { // Anything else, including RPC transport errors.}
Aria2Exception is the base type for the public API.
RpcException is a JSON-RPC transport or protocol error. It exposes method() and payload().
TransferFailedException is thrown when download() fails. Use fromDownload() to wrap a downloader error.
TransferCancelledException is thrown when download() stops because of a cancel signal.
DownloadFailedException is an internal downloader failure and does not extend Aria2Exception. The pending transfer wraps it.
download() always throws a public exception (TransferFailedException or TransferCancelledException). You should not need to catch DownloadFailedException from application code.