Lemme back up, b/c I have pure code sandwiched bet...
# arrow
d
Lemme back up, b/c I have pure code sandwiched between two effects. Maybe it's preferable to change this...
Copy code
fx {
                val response = !effect {
                    call("$accountsHost/private/${accountId.value}/signup_notifications/${notificationId.value}") {
                        method = Get
                        headers.appendAll(this@AccountsGateway.headers)
                    }.response
                }
                Try<Unit> {
                    when (response.status) {
                        InternalServerError -> throw AccountsGatewayException("Failed to get info for notification_id ${notificationId.value} on account ${accountId.value}. ${response.status.description}")
                        Gone -> throw NotificationDeletedException()
                    }
                }.fromTry { e -> e }.bind()
                !effect {
                    try {
                        response.receive<SignupNotificationInfo>()
                    } catch(e: NoTransformationFoundException) {
                        throw AccountsGatewayException("The accounts service did not return valid json for notification_id ${notificationId.value} in account ${accountId.value}")
                    }
                }
            }.attempt()
into this?
Copy code
fx {
                !effect {
                    val response = call("$accountsHost/private/${accountId.value}/signup_notifications/${notificationId.value}") {
                        method = Get
                        headers.appendAll(this@AccountsGateway.headers)
                    }.response
                    when (response.status) {
                        InternalServerError -> throw AccountsGatewayException("Failed to get info for notification_id ${notificationId.value} on account ${accountId.value}. ${response.status.description}")
                        Gone -> throw NotificationDeletedException()
                    }
                    try {
                        response.receive<SignupNotificationInfo>()
                    } catch(e: NoTransformationFoundException) {
                        throw AccountsGatewayException("The accounts service did not return valid json for notification_id ${notificationId.value} in account ${accountId.value}")
                    }
                }
            }.attempt()