This document lists all error codes that can be returned by the headless library.
All errors follow the SheetError interface:
interface SheetError {
readonly code: string;
readonly params?: Readonly<Record<string, unknown>>;
readonly level?: 'error' | 'warning' | 'fatal' | 'info';
readonly message?: string;
readonly rowIndex?: number;
readonly cellKey?: string;
}These errors are returned in useSheetData().errors when the parser fails before creating a sheet.
Level: fatal
Description: The parser failed to read or parse the file. This can occur due to:
- Corrupted file
- Unsupported file format
- Invalid file structure
- Worker crash during parsing
Params:
fileName: Name of the file that failed to parsefileSize: Size of the file in bytesfileType: MIME type of the fileoriginalError: Original error message from the parser
Example:
{
"code": "PARSER_FAILED",
"level": "fatal",
"message": "Failed to parse the file. The file may be corrupted or in an unsupported format.",
"params": {
"fileName": "data.csv",
"fileSize": 1024,
"fileType": "text/csv",
"originalError": "Unexpected end of file"
}
}How to handle:
- Check if the file is corrupted
- Verify the file format matches the expected type (CSV, XLSX, etc.)
- Try re-uploading the file
- Check the
originalErrorparam for specific details
Level: fatal
Description: The parser successfully read the file but found no sheets. This can occur when:
- The file is empty
- The file structure is invalid
- All sheets in the workbook are empty
Params:
fileName: Name of the filefileSize: Size of the file in bytesfileType: MIME type of the file
Example:
{
"code": "PARSER_NO_SHEETS",
"level": "fatal",
"message": "No sheets found in the file. The file may be empty or corrupted.",
"params": {
"fileName": "empty.xlsx",
"fileSize": 512,
"fileType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
}How to handle:
- Verify the file is not empty
- Open the file in Excel/LibreOffice to check if it contains data
- Ensure the file has at least one sheet with data
Level: fatal
Description: The parser found sheets in the file but failed to access the first sheet. This is an internal error that should not normally occur.
Params:
fileName: Name of the file
Example:
{
"code": "PARSER_SHEET_ACCESS_FAILED",
"level": "fatal",
"message": "Failed to access the first sheet in the file.",
"params": {
"fileName": "data.xlsx"
}
}How to handle:
- This is likely a bug in the library
- Try re-uploading the file
- If the issue persists, report it as a bug with the file attached
These errors are attached to specific cells in the sheet (cell.errors).
Level: error
Description: The cell value is not a valid email address.
Params:
value: The invalid value
Example:
{
"code": "INVALID_EMAIL",
"level": "error",
"message": "Invalid email address",
"cellKey": "email",
"rowIndex": 5,
"params": {
"value": "not-an-email"
}
}Level: error
Description: A required field is empty or null.
Params:
fieldName: Name of the required field
Example:
{
"code": "REQUIRED_FIELD_MISSING",
"level": "error",
"message": "This field is required",
"cellKey": "name",
"rowIndex": 10,
"params": {
"fieldName": "name"
}
}These errors occur when table-level validators or transforms call external APIs.
Level: error
Description: An async table-level validator failed to complete due to an external error (network, timeout, server error).
Params:
reason: One of'network','timeout','server_error'
Example:
{
"code": "EXTERNAL_VALIDATION_FAILED",
"level": "error",
"message": "External validation failed due to network error",
"params": {
"reason": "network"
}
}How to handle:
- Network error: Check internet connection and retry
- Timeout: The request took too long; retry or increase timeout
- Server error: The backend returned an error; check server logs
Level: error
Description: An async table-level transform failed to complete due to an external error.
Params:
reason: One of'network','timeout','server_error'
Example:
{
"code": "EXTERNAL_TRANSFORM_FAILED",
"level": "error",
"message": "External transform failed due to timeout",
"params": {
"reason": "timeout"
}
}Global errors are available when the status is error and no sheet has been created yet:
const { errors } = useSheetData();
// When status is 'error' and sheet is null, errors will contain global errors
if (status === 'error' && !sheet && errors.length > 0) {
const globalError = errors[0];
console.error(`Parser failed: ${globalError.message}`);
console.error(`Code: ${globalError.code}`);
console.error(`Params:`, globalError.params);
}Sheet errors are available when a sheet exists:
const { sheet, errors } = useSheetData();
// errors contains both global errors and sheet.errors
if (errors.length > 0) {
errors.forEach((error) => {
if (error.rowIndex !== undefined && error.cellKey) {
console.error(
`Cell error at row ${error.rowIndex}, column ${error.cellKey}: ${error.message}`
);
} else if (error.rowIndex !== undefined) {
console.error(`Row error at row ${error.rowIndex}: ${error.message}`);
} else {
console.error(`Global error: ${error.message}`);
}
});
}function ErrorDisplay() {
const { errors, sheet } = useSheetData();
const { status } = useImporterStatus();
if (status === 'error' && !sheet) {
// Fatal error: parser failed
const fatalError = errors[0];
return (
<div className="error-banner">
<h3>Failed to process file</h3>
<p>{fatalError?.message}</p>
{fatalError?.code === 'PARSER_FAILED' && (
<p>Please check that the file is not corrupted and is in a supported format (CSV, XLSX).</p>
)}
</div>
);
}
if (errors.length > 0) {
// Validation errors
return (
<div className="validation-errors">
<h3>{errors.length} validation error(s) found</h3>
<ul>
{errors.map((error, i) => (
<li key={i}>
{error.rowIndex !== undefined && `Row ${error.rowIndex + 1}: `}
{error.message}
</li>
))}
</ul>
</div>
);
}
return null;
}Error codes are designed to be language-agnostic. The message field is a fallback in English, but you should translate errors based on the code and params:
const errorMessages = {
en: {
PARSER_FAILED: 'Failed to parse the file. Please check the file format.',
PARSER_NO_SHEETS: 'The file is empty or contains no data.',
INVALID_EMAIL: 'Invalid email address',
REQUIRED_FIELD_MISSING: 'This field is required',
},
es: {
PARSER_FAILED: 'No se pudo procesar el archivo. Verifica el formato.',
PARSER_NO_SHEETS: 'El archivo está vacío o no contiene datos.',
INVALID_EMAIL: 'Dirección de correo inválida',
REQUIRED_FIELD_MISSING: 'Este campo es obligatorio',
},
};
function translateError(error: SheetError, locale: string): string {
return errorMessages[locale]?.[error.code] ?? error.message ?? error.code;
}