Skip to content

Commit

Permalink
Merge pull request #3 from martinmaillard/error-handling
Browse files Browse the repository at this point in the history
Avoid swallowing errors from FTP client
  • Loading branch information
martinmaillard authored Sep 23, 2019
2 parents 7ffa9db + 6426151 commit 548e706
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ftp/lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ async function command (options, callback, keepAlive = false) {

return result
} catch (err) {
return client.disconnect()
await client.disconnect()
throw err
}
}

Expand Down
11 changes: 11 additions & 0 deletions packages/ftp/test/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,15 @@ describe('list', () => {

expect(filenames).toEqual(['data/abc.txt', 'data/xyz.txt'])
})

it('throws proper error when file does not exist', async () => {
const server = new FtpServer()
await server.start()

await expect(list({ pathname: 'does-not-exist', ...server.options }))
.rejects
.toThrow('no such file or directory')

await server.stop()
})
})

0 comments on commit 548e706

Please sign in to comment.