Error Handling Overview
All our functions will throw one of these four types of errors:
- SuperTokensGeneralException
- SuperTokensUnauthorisedException
- SuperTokensTryRefreshTokenException
- SuperTokensTokenTheftException
Example
Route::post('/like-comment', function (Illuminate\Http\Request $request) {
$response = new \Illuminate\Http\Response();
try {
$session = SuperTokens\SuperTokens::getSession($request, $response, true);
// API logic..
} catch(SuperTokensTryRefreshTokenException $e) {
$response->setStatusCode(440)->setContent("Try refresh token");
} catch (SuperTokensUnauthorisedException $e) {
$response->setStatusCode(440)->setContent("Please login again");
} catch(SuperTokensGeneralException $e) {
$response->setStatusCode(500)->setContent("Something went wrong");
}
return $response;
});