Logcat: catat exception SSH asli saat koneksi gagal

Tambah Log.e(TAG, ..., e) di catch untuk menampilkan stacktrace / pesan
error sebenarnya (ConnectException, AuthFailException, UnknownHost, dll)
di logcat. Memudahkan diagnosa 'koneksi gagal setelah N percobaan'.
This commit is contained in:
2026-08-30 23:51:13 +07:00
parent 3cbb626d4a
commit 0d3038f9a9

View File

@@ -1,5 +1,6 @@
package com.kosbarokah.sshclient.ssh package com.kosbarokah.sshclient.ssh
import android.util.Log
import com.kosbarokah.sshclient.data.AuthMethod import com.kosbarokah.sshclient.data.AuthMethod
import com.kosbarokah.sshclient.data.ServerProfile import com.kosbarokah.sshclient.data.ServerProfile
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@@ -37,6 +38,10 @@ class SshEngine(
private val passwordPolicy: PasswordPolicy = PasswordPolicy.DENY_INTERACTIVE_PROMPT private val passwordPolicy: PasswordPolicy = PasswordPolicy.DENY_INTERACTIVE_PROMPT
) { ) {
companion object {
private const val TAG = "SSHClient/SshEngine"
}
enum class PasswordPolicy { enum class PasswordPolicy {
/** Do not auto-answer interactive password/kbf prompts. */ /** Do not auto-answer interactive password/kbf prompts. */
DENY_INTERACTIVE_PROMPT, DENY_INTERACTIVE_PROMPT,
@@ -83,6 +88,7 @@ class SshEngine(
// connected — this loop continues only on disconnection // connected — this loop continues only on disconnection
} catch (e: Exception) { } catch (e: Exception) {
val msg = e.message ?: "koneksi gagal" val msg = e.message ?: "koneksi gagal"
Log.e(TAG, "SSH koneksi gagal (percobaan ${attempt}): $msg", e)
if (!running) break if (!running) break
val willRetry = attempt < maxReconnectAttempts val willRetry = attempt < maxReconnectAttempts
if (willRetry) { if (willRetry) {