Skip to content

Commit b7caada

Browse files
committed
Fix Laravel 8 compatibility
Closes #185
1 parent b48fe8d commit b7caada

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/Drivers/HttpDriver.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ public static function resolveHttpBy(Closure $callback): void
3333
*/
3434
public function process(Request $request): Fluent|false
3535
{
36-
return rescue(fn () => new Fluent(
37-
$this->http()
38-
->throw()
39-
->acceptJson()
40-
->get($this->url($request->getIp()))
41-
->json()
42-
), false, false);
36+
return rescue(function () use ($request) {
37+
$response = $this->http()->acceptJson()->get(
38+
$this->url($request->getIp())
39+
);
40+
41+
throw_if($response->failed());
42+
43+
return new Fluent($response->json());
44+
}, false, false);
4345
}
4446

4547
/**

src/Drivers/MaxMind.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PharData;
1616
use PharFileInfo;
1717
use RecursiveIteratorIterator;
18+
use RuntimeException;
1819
use Stevebauman\Location\Position;
1920
use Stevebauman\Location\Request;
2021

@@ -38,10 +39,15 @@ public function update(Command $command): void
3839
$tarFileName = 'maxmind.tar.gz'
3940
);
4041

41-
Http::withOptions(['sink' => $tarFilePath])->throw()->get(
42+
$response = Http::withOptions(['sink' => $tarFilePath])->get(
4243
$this->getDatabaseUrl()
4344
);
4445

46+
throw_if(
47+
$response->failed(),
48+
new RuntimeException('Failed to download MaxMind database. Response: '.$response->body())
49+
);
50+
4551
$archive = new PharData($tarFilePath);
4652

4753
$file = $this->discoverDatabaseFile($archive);

0 commit comments

Comments
 (0)