Skip to content

Modify 500 code error response page #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NikitaYakovlev
Copy link

refs: #163

Copy link

sonarqubecloud bot commented Apr 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
3.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rename file to error.blade.php, need to unlink logic from the swagger usage only

@@ -30,7 +30,7 @@ public function saveData(): void
public function getDocumentation(): array
{
if (!file_exists($this->prodFilePath)) {
throw new FileNotFoundException();
throw new FileNotFoundException("Documentation file not found :{$this->prodFilePath}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move error message to the exception and just pass the path as arg

Suggested change
throw new FileNotFoundException("Documentation file not found :{$this->prodFilePath}");
throw new FileNotFoundException($this->prodFilePath);

@@ -138,7 +138,21 @@ protected function generateEmptyData(): array
throw new EmptyContactEmailException();
}

$data = [
$data = $this->generateBaseDataObject();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need to make this change, could you please revert it?

$documentation = $this->driver->getDocumentation();

$this->openAPIValidator->validate($documentation);
} catch (\Exception $exception) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch (\Exception $exception) {
} catch (Exception $exception) {


$this->openAPIValidator->validate($documentation);
$this->config['info'] = Arr::set($this->config, 'info.description', Arr::get($this->config, 'defaults.error'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's pass the description view as arg, it would be better to redefine the config field

app(SwaggerService::class)->getDocFileContent();
$description = Arr::get($content, 'info.description');

$this->assertEquals($exceptionMessage, Str::replace(''', "'", $description));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to assert rendered error view instead of

@DenTray DenTray assigned yogyrton and unassigned DenTray Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants