Commit next part of FS#10138 by Teruaki Kawashima. Fixes mistaken error return value...