Skip to content

Commit

Permalink
Throw an exception on invalid Node URI
Browse files Browse the repository at this point in the history
  • Loading branch information
owenvoke committed Jun 3, 2019
1 parent a1a1eda commit a61068d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Exceptions/InvalidNodeUriException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace pxgamer\Arionum\Exceptions;

final class InvalidNodeUriException extends ArionumException
{
}
5 changes: 5 additions & 0 deletions src/Laravel/ArionumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace pxgamer\Arionum\Laravel;

use pxgamer\Arionum\Arionum;
use pxgamer\Arionum\Exceptions\InvalidNodeUriException;
use Illuminate\Support\ServiceProvider;

final class ArionumServiceProvider extends ServiceProvider
Expand All @@ -17,6 +18,10 @@ public function boot(): void
public function register(): void
{
$this->app->singleton(Arionum::class, function () {
if (!$this->app->get('config')->get('arionum.node-uri')) {
throw new InvalidNodeUriException('The configured node uri is invalid. A valid `ARIONUM_NODE_URI` variable should be configured in your environment');
}

return new Arionum($this->app->get('config')->get('arionum.node-uri'));
});

Expand Down

0 comments on commit a61068d

Please sign in to comment.