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 Pullr\LaravelAria2\Exceptions\Aria2Exception;use Pullr\LaravelAria2\Exceptions\TransferCancelledException;use Pullr\LaravelAria2\Exceptions\TransferFailedException;use Pullr\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.}
Hierarchy
| Class | When |
| --- | --- |
| Aria2Exception | Base type for the public API. |
| RpcException | JSON-RPC transport or protocol error. Has method() and payload(). |
| TransferFailedException | download() failed. Use fromDownload() to wrap a downloader error. |
| TransferCancelledException | download() stopped because of a cancel signal. |
| DownloadFailedException | Internal downloader failure (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.