[refactor] 全体的にエラーハンドリング漏れの修正 - #150
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors various components of the codebase to improve error handling across controllers, use cases, and infrastructure layers. Key changes include adding proper error handling for multipart form parsing, UUID generation, JWT token issuance, and request validations, as well as fixing typos in function names and log messages.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| file-server/pkg/controller/file.go | Updated error handling and response formatting in file uploads |
| app/usecase/userinfo.go | Fixed typo in NewUserinfoUseCase function name |
| app/usecase/comment.go | Fixed typo in NewCommentUseCase function name and improved UUID error handling |
| app/usecase/auth.go | Added error checks for JWT token generation |
| app/interfaces/server.go | Fixed typo in instantiating use cases and handlers |
| app/interfaces/handler/*.go | Replaced error handling via utils.Validate and updated response handling |
| app/infrastructure/comment.go | Updated NewCommentRepository return type for improved type clarity |
| app/configs/conn.go | Fixed typo in log message for failed database connection |
| return | ||
| } | ||
|
|
||
| urlName := fmt.Sprintf("http://localhost:3004/%s%s", uuID, file.Filename) |
There was a problem hiding this comment.
Consider adding an explicit separator (e.g., '/') between the UUID and file.Filename to ensure that the generated URL is always correctly formatted, especially when file.Filename may not start with a '/'.
Suggested change
| urlName := fmt.Sprintf("http://localhost:3004/%s%s", uuID, file.Filename) | |
| sanitizedFilename := file.Filename | |
| if len(sanitizedFilename) > 0 && sanitizedFilename[0] == '/' { | |
| sanitizedFilename = sanitizedFilename[1:] | |
| } | |
| urlName := fmt.Sprintf("http://localhost:3004/%s/%s", uuID, sanitizedFilename) |
static-fuji
self-requested a review
June 30, 2025 06:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
エラーハンドリングを中心に,全体的に見直して修正しました.
使われていなかった戻り値のエラー処理を追加して,処理が途中で失敗しても気付きやすくしました.
追加で,CIも追加しました
変更点
utils.Validateやauth.IssueUserTokenのエラー処理を追加workIDの取得をchi.URLParamに変更commentRepositoryImplの戻り値型を明示UsecaceをUseCaseに修正(タイポ修正)