fix: gracefully fail if symbol not found
This commit is contained in:
@@ -14,8 +14,17 @@ class MarketDataController extends ApiController
|
|||||||
public function show(Request $request, string $symbol)
|
public function show(Request $request, string $symbol)
|
||||||
{
|
{
|
||||||
|
|
||||||
return MarketDataResource::make(
|
try {
|
||||||
MarketData::getMarketData($symbol)
|
|
||||||
);
|
return MarketDataResource::make(
|
||||||
|
MarketData::getMarketData($symbol)
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
|
||||||
|
return response([
|
||||||
|
'message' => 'Symbol '.$symbol.' not found.',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user