Skip to content

internal: Refactor DesignException handling to use unified DesignErrorCode enum#67

Merged
xerial merged 2 commits intomainfrom
feature/20250516_222438
May 17, 2025
Merged

internal: Refactor DesignException handling to use unified DesignErrorCode enum#67
xerial merged 2 commits intomainfrom
feature/20250516_222438

Conversation

@xerial
Copy link
Copy Markdown
Member

@xerial xerial commented May 17, 2025

Description

Refactored DesignException handling to integrate the use of a unified DesignErrorCode enum, improving consistency and maintainability.

Related Issue/Task

N/A

Checklist

  • This pull request focuses on a single task.
  • The change does not contain security credentials

@amazon-q-developer
Copy link
Copy Markdown
Contributor

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@github-actions github-actions Bot added the internal Non-user facing changes label May 17, 2025
cause
)

case class DesignException(code: DesignErrorCode, message: String, cause: Throwable = null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Description: DesignException class doesn't override getMessage method, which may lead to inconsistent error reporting. Override getMessage method in DesignException class to return a formatted string including the error code.

Severity: Medium

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix addresses the comment by overriding the getMessage method in the DesignException class to include the error code in the formatted string. The toString method is also updated to use the new getMessage implementation, ensuring consistent error reporting. This change provides a more informative error message that includes both the error code and the original message.

Suggested change
case class DesignException(code: DesignErrorCode, message: String, cause: Throwable = null)
case class DesignException(code: DesignErrorCode, message: String, cause: Throwable = null)
extends Exception(message, cause):
override def getMessage: String = s"[${code}] ${super.getMessage}"
override def toString: String = getMessage
object DesignException:
def cyclicDependency(deps: List[Surface], sourceCode: SourceCode): DesignException =

@amazon-q-developer
Copy link
Copy Markdown
Contributor

✅ I finished the code review, and left comments with the issues I found. I will now generate code fix suggestions.

@xerial xerial enabled auto-merge (squash) May 17, 2025 06:04
@xerial xerial merged commit 8d0446e into main May 17, 2025
10 checks passed
@xerial xerial deleted the feature/20250516_222438 branch May 17, 2025 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Non-user facing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant