{"record":{"id":"b74d99471f896efa","repo":"pentaho/pentaho-kettle","slug":"the-function-call-is-file-throw-an-error-e-tostring","errorCode":null,"errorMessage":"The function call is File throw an error :  + e.toString()","messagePattern":"The function call is File throw an error :  \\+ e\\.toString\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2149,"sourceCode":"        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );\n          boolean isafile = false;\n          if ( file.exists() ) {\n            if ( file.getType().equals( FileType.FILE ) ) {\n              isafile = true;\n            } else {\n              throw new RuntimeException( \"[\" + ArgList[0] + \"] is not a file!\" );\n            }\n          } else {\n            throw new RuntimeException( \"file [\" + ArgList[0] + \"] can not be found!\" );\n          }\n          return isafile;\n        } catch ( IOException e ) {\n          throw new RuntimeException( \"The function call is File throw an error : \" + e.toString() );\n        } finally {\n          if ( file != null ) {\n            try {\n              file.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n        }\n\n      } else {\n        throw new RuntimeException( \"The function call isFile is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e.toString() );\n    }\n  }\n","sourceCodeStart":2131,"sourceCodeEnd":2167,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2131-L2167","documentation":"Thrown by ScriptAddedFunctions.isFile when an IOException occurs while resolving or closing the VFS file object. The IOException is caught and rethrown as a RuntimeException with message 'The function call is File throw an error : ' plus e.toString(), so the original cause text appears after the prefix.","triggerScenarios":"KettleVFS.getInstance(bowl).getFileObject(path) or file.close() throws IOException: malformed VFS URI, remote filesystem unreachable, permission/I/O errors during resolution.","commonSituations":"SFTP/HTTP VFS providers failing due to network or auth problems, URIs with unescaped special characters, and transient remote-filesystem outages.","solutions":["Read the cause text after the 'is File throw an error : ' prefix to find the real IOException.","Validate the VFS URI format and credentials (scheme, host, user) for remote filesystems.","Retry if the failure was transient (network blip on sftp/http providers).","Escape special characters in the path or switch to a local-path equivalent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var f = new java.io.File(path);\nif (f.exists() && f.canRead()) {\n  var ok = isFile(path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  ok = isFile(path);\n} catch (e) {\n  // message is 'The function call is File throw an error : ' + cause\n  Logger.logError('isFile failed: ' + e.message);\n}","preventionTips":["Validate VFS URI format and credentials for remote providers.","Handle transient network failures with retries outside the JS step.","Prefer local staging copies for remote files."],"tags":["kettle","javascript-step","io","vfs"],"backgroundTag":"file-read-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}