{"record":{"id":"31acb28d89b24fd2","repo":"pentaho/pentaho-kettle","slug":"fileerrorhandlercontentlinenumber-exception","errorCode":"FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine","errorMessage":"FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine","messagePattern":"FileErrorHandlerContentLineNumber\\.Exception\\.CouldNotCreateWriteLine","errorType":"error_code","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/step/errorhandling/FileErrorHandlerContentLineNumber.java","lineNumber":38,"sourceCode":"import org.pentaho.di.core.Const;\nimport org.pentaho.di.core.exception.KettleException;\nimport org.pentaho.di.i18n.BaseMessages;\nimport org.pentaho.di.trans.step.BaseStep;\n\npublic class FileErrorHandlerContentLineNumber extends AbstractFileErrorHandler {\n  private static Class<?> PKG = FileErrorHandlerContentLineNumber.class; // for i18n purposes, needed by Translator2!!\n\n  public FileErrorHandlerContentLineNumber( Date date, String destinationDirectory, String fileExtension,\n    String encoding, BaseStep baseStep ) {\n    super( date, destinationDirectory, fileExtension, encoding, baseStep );\n  }\n\n  public void handleLineError( long lineNr, String filePart ) throws KettleException {\n    try {\n      getWriter( filePart ).write( String.valueOf( lineNr ) );\n      getWriter( filePart ).write( Const.CR );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString(\n        PKG, \"FileErrorHandlerContentLineNumber.Exception.CouldNotCreateWriteLine\" )\n        + lineNr, e );\n\n    }\n  }\n\n  public void handleNonExistantFile( FileObject file ) {\n  }\n\n  public void handleNonAccessibleFile( FileObject file ) {\n  }\n\n}\n","sourceCodeStart":20,"sourceCodeEnd":52,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/step/errorhandling/FileErrorHandlerContentLineNumber.java#L20-L52","documentation":"KettleException thrown by FileErrorHandlerContentLineNumber.handleLineError() when writing the line number of a rejected row to the content-error file fails. The line number itself is fine — the failure is in obtaining or writing to the underlying writer (delegated to AbstractFileErrorHandler.getWriter).","triggerScenarios":"handleLineError(lineNr, filePart) called for each bad row; getWriter(filePart).write(...) throws because the error file could not be created/opened (see file-open failures) or the write itself failed (disk full, stream closed).","commonSituations":"Text file input steps with error handling enabled where the error directory is missing/read-only; first bad row triggers lazy writer creation which then fails; disk fills mid-run after many bad lines.","solutions":["Fix the error-handling file location: ensure it exists, is writable, and the URI is valid (see the chained cause)","Check the chained KettleException cause — it's usually a file-open failure from AbstractFileErrorHandler.getWriter","Free disk space if writes fail mid-run; monitor for excessive bad rows flooding the error file","Pre-test error handling settings with a small sample file in Spoon"],"exampleFix":"// before: error dir missing\n<p>Bad rows go to /logs/lineage (nonexistent)</p>\n// after\nmkdir -p /logs/lineage && chmod u+w /logs/lineage","handlingStrategy":"validation","validationCode":"// Pre-flight the lineage target before processing rows\nFileObject lineage = KettleVFS.getInstance(DefaultBowl.getInstance())\n  .getFileObject(errorFileUri);\nif (!lineage.getParent().exists() || !lineage.getParent().isWriteable()) {\n  throw new KettleException(\"Lineage file location not writable: \" + errorFileUri);\n}","typeGuard":null,"tryCatchPattern":"try {\n  errorHandler.handleLineError(lineNr, part);\n} catch (KettleException e) {\n  log.error(\"Could not record bad line \" + lineNr + \": \" + e.getMessage(), e);\n  // stop the run rather than silently losing lineage records\n  throw e;\n}","preventionTips":["Validate error-directory existence/writability at transformation startup","Cap bad-row volume with step error-handling limits (max errors) so disk can't fill","Watch disk usage; lineage files grow per bad row"],"tags":["file-io","error-handling","write"],"backgroundTag":"file-write-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"}