diff --git a/src/api/IBMi.ts b/src/api/IBMi.ts index af0c40a62..763881ba5 100644 --- a/src/api/IBMi.ts +++ b/src/api/IBMi.ts @@ -874,7 +874,7 @@ export default class IBMi { }; }); - } catch (e) { + } catch (e: any) { if (this.client.isConnected()) { this.client.dispose(); @@ -887,9 +887,20 @@ export default class IBMi { return this.connect(connectionObject, true); } + let error = e; + if (e.code === "ENOTFOUND") { + error = `Host is unreachable. Check the connection's hostname/IP address.`; + } + else if (e.code === "ECONNREFUSED") { + error = `Port ${connectionObject.port} is unreachable. Check the connection's port number or run command STRTCPSVR SERVER(*SSHD) on the host.` + } + else if (e.level === "client-authentication") { + error = `Check your credentials${e.message ? ` (${e.message})` : ''}.`; + } + return { success: false, - error: e + error }; } finally { @@ -1142,4 +1153,4 @@ export default class IBMi { return file.fsPath; } } -} +} \ No newline at end of file