Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Feb 20, 2024
1 parent 99332a9 commit 13badb6
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.example.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest;
import com.example.daemawiki.domain.revision.model.type.RevisionType;
import com.example.daemawiki.domain.user.model.User;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;

Expand All @@ -34,7 +35,8 @@ public Mono<DefaultDocument> execute(User user) {
.documentId(document.getId())
.title(document.getTitle())
.build())
.thenReturn(document));
.thenReturn(document))
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

private DefaultDocument createDocument(User user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.example.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest;
import com.example.daemawiki.domain.revision.model.type.RevisionType;
import com.example.daemawiki.domain.user.service.facade.UserFacade;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

Expand All @@ -32,7 +33,8 @@ public Mono<Void> execute(SaveDocumentRequest request) {
.type(RevisionType.CREATE)
.documentId(document.getId())
.title(document.getTitle())
.build()));
.build()))
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.example.daemawiki.domain.document.component.service;

import com.example.daemawiki.domain.document.repository.DocumentRepository;
import com.example.daemawiki.domain.revision.component.RevisionComponent;
import com.example.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest;
import com.example.daemawiki.domain.revision.model.type.RevisionType;
import com.example.daemawiki.domain.revision.component.RevisionComponent;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

Expand All @@ -24,7 +25,8 @@ public Mono<Void> execute(String documentId) {
.type(RevisionType.DELETE)
.documentId(documentId)
.title(document.getTitle())
.build())));
.build())))
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.example.daemawiki.domain.document.component.service;

import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
import com.example.daemawiki.domain.document.dto.request.SaveDocumentRequest;
import com.example.daemawiki.domain.document.model.type.service.GetDocumentType;
import com.example.daemawiki.domain.document.repository.DocumentRepository;
import com.example.daemawiki.domain.document.component.facade.DocumentFacade;
import com.example.daemawiki.domain.revision.component.RevisionComponent;
import com.example.daemawiki.domain.revision.dto.request.SaveRevisionHistoryRequest;
import com.example.daemawiki.domain.revision.model.type.RevisionType;
import com.example.daemawiki.domain.user.dto.UserDetailResponse;
import com.example.daemawiki.domain.user.service.facade.UserFacade;
import com.example.daemawiki.global.exception.h400.VersionMismatchException;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

Expand Down Expand Up @@ -60,7 +61,8 @@ public Mono<Void> execute(SaveDocumentRequest request, String documentId) {
.type(RevisionType.UPDATE)
.documentId(d.getId())
.title(d.getTitle())
.build()));
.build()))
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.daemawiki.domain.revision.model.RevisionHistory;
import com.example.daemawiki.domain.revision.repository.RevisionHistoryRepository;
import com.example.daemawiki.domain.user.service.facade.UserFacade;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;

Expand All @@ -29,7 +30,8 @@ public Mono<Void> saveHistory(SaveRevisionHistoryRequest request) {
.createdDateTime(LocalDateTime.now())
.build())
.flatMap(revisionHistoryRepository::save)
.then();
.then()
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.example.daemawiki.domain.user.dto.ChangePasswordRequest;
import com.example.daemawiki.domain.user.repository.UserRepository;
import com.example.daemawiki.domain.user.service.facade.UserFacade;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
Expand All @@ -27,6 +28,7 @@ public Mono<Void> execute(ChangePasswordRequest request) {
user.changePassword(passwordEncoder.encode(request.newPassword()));
return userRepository.save(user);
})
.onErrorMap(e -> ExecuteFailedException.EXCEPTION)
.then();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.daemawiki.domain.user.repository.UserRepository;
import com.example.daemawiki.domain.user.service.facade.UserFacade;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import com.example.daemawiki.infra.s3.service.S3UploadObject;
import org.springframework.http.codec.multipart.FilePart;
import org.springframework.stereotype.Service;
Expand All @@ -26,6 +27,7 @@ public Mono<Void> execute(FilePart filePart) {
return user;
})
.flatMap(userRepository::save)
.onErrorMap(e -> ExecuteFailedException.EXCEPTION)
.then();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.daemawiki.domain.file.dto.DeleteFileRequest;
import com.example.daemawiki.domain.file.component.DeleteFile;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
Expand All @@ -28,7 +29,8 @@ public Mono<Void> deleteObject(DeleteFileRequest request) {
.build())
.map(s3AsyncClient::deleteObject)
.flatMap(Mono::fromFuture)
.flatMap(deleteObjectResponse -> deleteFile.deleteById(request.key()));
.flatMap(deleteObjectResponse -> deleteFile.deleteById(request.key()))
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.daemawiki.domain.file.model.FileDetail;
import com.example.daemawiki.domain.file.model.type.FileType;
import com.example.daemawiki.domain.file.repository.FileRepository;
import com.example.daemawiki.global.exception.h500.ExecuteFailedException;
import com.example.daemawiki.global.exception.h500.FileUploadFailedException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.buffer.DataBufferUtils;
Expand Down Expand Up @@ -83,7 +84,8 @@ public Mono<File> uploadObject(FilePart filePart, String fileType) {
.onErrorMap(e -> FileUploadFailedException.EXCEPTION);
});
})
.flatMap(response -> createFile(key, filename, type, fileType));
.flatMap(response -> createFile(key, filename, type, fileType))
.onErrorMap(e -> ExecuteFailedException.EXCEPTION);
}

private Mono<File> createFile(UUID key, String fileName, MediaType mediaType, String filetype) {
Expand Down

0 comments on commit 13badb6

Please sign in to comment.