Skip to content

Conversation

RGO230
Copy link
Contributor

@RGO230 RGO230 commented Jul 2, 2025

@RGO230 RGO230 self-assigned this Jul 2, 2025
@RGO230 RGO230 assigned AZabolotnikov and RGO230 and unassigned RGO230 and AZabolotnikov Jul 3, 2025
@RGO230 RGO230 assigned AZabolotnikov and unassigned RGO230 Jul 9, 2025
Copy link

sonarqubecloud bot commented Jul 9, 2025

} catch (Exception $exception) {
return $this->generateEmptyData($this->config['defaults']['error'], ['message' => $exception->getMessage()]);
} catch (Throwable $exception) {
$message = $exception instanceof Exception ? $exception->getMessage() : '[]';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$message = $exception instanceof Exception ? $exception->getMessage() : '[]';
$message = ($exception instanceof Exception) ? $exception->getMessage() : '[]';

Copy link
Contributor

Choose a reason for hiding this comment

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

@RGO230 @DenTray

Why we can't always write message?
For me always show $exception->getMessage() is fine. What are we trying to hide here?

if we trying hide only next Throwable message 'RonasIT\AutoDoc\Drivers\LocalDriver::getDocumentation(): Return value must be of type array, null returned'. Maybe we can write like kind "Documentation file is empty or have bad format" insted []

Copy link
Collaborator

Choose a reason for hiding this comment

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

@AZabolotnikov I don't mind of your way

@RGO230 any reasons to make an additional check?

@AZabolotnikov AZabolotnikov assigned DenTray and RGO230 and unassigned AZabolotnikov Jul 31, 2025
} catch (Exception $exception) {
return $this->generateEmptyData($this->config['defaults']['error'], ['message' => $exception->getMessage()]);
} catch (Throwable $exception) {
$message = $exception instanceof Exception ? $exception->getMessage() : '[]';
Copy link
Collaborator

Choose a reason for hiding this comment

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

@AZabolotnikov I don't mind of your way

@RGO230 any reasons to make an additional check?

@DenTray DenTray removed their assignment Aug 12, 2025
@astorozhevsky astorozhevsky requested a review from Copilot August 28, 2025 09:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modifies the error response page formatting for Swagger validation errors, addressing issue #163. The changes enhance error presentation with structured markdown formatting and proper error context display.

  • Reformats error page display with markdown structure including headers and visual separators
  • Updates error handling to include exception type information alongside error messages
  • Fixes test parameter ordering and adds new test case for incorrect documentation structure

Reviewed Changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
resources/views/error.blade.php Updates error page template with structured markdown formatting
src/Services/SwaggerService.php Modifies exception handling to capture and pass exception type information
tests/SwaggerServiceTest.php Updates test expectations and adds new test case for documentation structure errors
tests/TestCase.php Fixes parameter order in exportContent method call
tests/fixtures/SwaggerServiceTest/*.html Updates all error fixture files to match new markdown-formatted error template

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

$this->expectException(EmptyContactEmailException::class);
$content = app(SwaggerService::class)->getDocFileContent();

$this->assertEqualsFixture('invalid_config_email.html', $content['info']['description'], true);

app(SwaggerService::class);
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

This line creates a new SwaggerService instance but doesn't use it. The test appears to be checking the error handling behavior, but this line won't trigger the expected error condition since the previous lines already retrieved the content. Remove this unused instantiation.

Suggested change
app(SwaggerService::class);

Copilot uses AI. Check for mistakes.

Comment on lines +140 to +145
$exception = new EmptyContactEmailException();

$viewData = [
'message' => $exception->getMessage(),
'type' => $exception::class,
];
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

Creating an exception instance without throwing it is unusual. The original code threw the exception, but now it's only created to extract the message. This changes the behavior from throwing an exception to returning error content, which may break existing error handling expectations.

Suggested change
$exception = new EmptyContactEmailException();
$viewData = [
'message' => $exception->getMessage(),
'type' => $exception::class,
];
throw new EmptyContactEmailException();

Copilot uses AI. Check for mistakes.

Copy link

sonarqubecloud bot commented Sep 1, 2025

@RGO230 RGO230 assigned AZabolotnikov and unassigned RGO230 Sep 1, 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