Skip to content

Commit

Permalink
switch to 500 with extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
petertgiles committed Jan 17, 2024
1 parent 95a84d0 commit fcaf836
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/app/Http/Controllers/SupportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class SupportController extends Controller
{
public function createTicket(Request $request)
{
if (! config('freshdesk.api.tickets_endpoint') || ! config('freshdesk.api.key')) {
Log::error('Attempted to create a ticket with missing config values.');

return response([
'apiResponse' => 'Missing parameters',
], 422);
], 500);
}
$parameters = [
'description' => $request->input('description'),
Expand Down Expand Up @@ -45,9 +48,11 @@ public function createTicket(Request $request)
'serviceResponse' => $response->json(),
], 200);
} else {
Log::error('Error when trying to create a ticket: '.$response->getBody(true));

return response([
'serviceResponse' => $response->json(),
], 400);
], 500);
}
}
}

0 comments on commit fcaf836

Please sign in to comment.