Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display more explicit error message when connection fails #1820

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/api/IBMi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ export default class IBMi {
};
});

} catch (e) {
} catch (e: any) {

if (this.client.isConnected()) {
this.client.dispose();
Expand All @@ -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 {
Expand Down Expand Up @@ -1142,4 +1153,4 @@ export default class IBMi {
return file.fsPath;
}
}
}
}