Conversation
| : FnsException("Login with phone $login failed", cause) | ||
|
|
||
| @ResponseStatus(code = HttpStatus.CONFLICT) | ||
| class UserWasExistException(userName: String, cause: Throwable? = null) |
There was a problem hiding this comment.
UserAlreadyExistsException
| throw UserWasExistException(name, e) | ||
| } catch (c: HttpClientErrorException.BadRequest) { | ||
| throw IncorrectEmailException(email, c) | ||
| } catch (d: HttpServerErrorException.InternalServerError) { |
There was a problem hiding this comment.
InternalServerError возникает буквально в любой непонятной ситуации.
Не всякий IE (InternalError) - это неправильный номер.
Есть варианты как понять что дело именно в номере?
Может, там приходит текст в ответ с описанием
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/excepion/FnsException.kt
Show resolved
Hide resolved
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Outdated
Show resolved
Hide resolved
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
|
|
||
| @Throws(IOException::class) | ||
| override fun handleError(httpResponse: ClientHttpResponse) { | ||
| when { |
There was a problem hiding this comment.
Внутри when какой то бесполезный код
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
| } | ||
|
|
||
| fun login(login: String, password: String) { | ||
| fun login(phone: String, password: String): ResponseEntity<UserResponseLoginFnsDto>? { |
There was a problem hiding this comment.
Тут нужно возвращать просто UserResponseLoginDto
|
|
||
| @Throws(IOException::class) | ||
| override fun handleError(httpResponse: ClientHttpResponse) { | ||
| if (httpResponse.statusCode == HttpStatus.NO_CONTENT) { |
There was a problem hiding this comment.
А если hasError всегда возвращает false, то разве он сюда вообще зайдет когда нибудь?
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
| package space.shefer.receipt.fnssdk.dto | ||
|
|
||
|
|
||
| class UserResponseLoginFnsDto { |
There was a problem hiding this comment.
Переименуй FnsLoginResponse
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/excepion/FnsException.kt
Outdated
Show resolved
Hide resolved
| } else if (responseEntity.statusCode == HttpStatus.INTERNAL_SERVER_ERROR) { | ||
| throw IncorrectPhoneException(phone) | ||
| } | ||
| } catch (e: Exception) { |
There was a problem hiding this comment.
зачем ловить Exception? какие ошибки мы тут ожидаем?
There was a problem hiding this comment.
ловлю UnsupportedOperationException, подозреваю что это дублирование кода, так как все ошибки я уже отработал в ResponseErrorHandleFNS
| if (authHeader != null) { | ||
| return fnsUserService.getUserByToken(authHeader.substring(authHeader.indexOf(" ") + 1)); | ||
| } | ||
| return null; |
| FnsLoginResponse responseEntity = fnsReceiptWebClient.login(userLoginDto.getPhone(), userLoginDto.getPassword()); | ||
| if (responseEntity != null) { | ||
| UserProfile userProfile = userProfileRepository.getByPhone(userLoginDto.getPhone()); | ||
| if (userProfile != null && userProfile.getUpdatedAt() == null) { |
There was a problem hiding this comment.
а зачем проверка updatedAt?
There was a problem hiding this comment.
изменил. Она тут не нужна, забыл убрать, логику переделал.
| @RequestMapping(value = "/users/me", method = RequestMethod.GET) | ||
| public UserSignUpDto getInfoByToken(@Nullable @RequestHeader("Authorization") String authHeader) { | ||
| if (authHeader != null) { | ||
| return fnsUserService.getUserByToken(authHeader.substring(authHeader.indexOf(" ") + 1)); |
There was a problem hiding this comment.
authHeader.substring(authHeader.indexOf(" ") + 1)
вынести в новый метод getTokenFromAuthHeader(String header)
| String::class.java | ||
| ) | ||
| FnsLoginResponse::class.java | ||
| ).body |
There was a problem hiding this comment.
поставь тут !! и в методе возвращаемый тип сделай без вопросика
There was a problem hiding this comment.
Расскажи подробнее, что это и как. Я даже не знаю как это загуглить)
| HttpEntity("""{"email":"$email","name":"$name","phone":"$phone"}""", headers), | ||
| String::class.java | ||
| ) | ||
| if (responseEntity.statusCode == HttpStatus.CONFLICT) { |
There was a problem hiding this comment.
сначала нужно проверить что если 2XX, то сразу return. иначе начинать перебиравть ифами ошибки
fns-sdk/src/main/kotlin/space/shefer/receipt/fnssdk/webclient/FnsReceiptWebClient.kt
Show resolved
Hide resolved
|
|
||
| @Throws(IOException::class) | ||
| override fun handleError(httpResponse: ClientHttpResponse) { | ||
| if (httpResponse.statusCode == HttpStatus.NO_CONTENT) { |
There was a problem hiding this comment.
этот код обрабатывает ошибки
а еще код в тоже обрабатываает эти же самые ошибки
нужно чтобы обрабатывалось все в FnsReceiptWebClient::signUp, а тут ничего не обрабатывалось
перенеси логику отсюда туда
hasError должен всегда возвращать false
No description provided.