-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement error handler #105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything serious so LGTM 👍
batchErrorHandler := csvcopy.BatchHandlerError() | ||
if skipBatchErrors { | ||
batchErrorHandler = csvcopy.BatchHandlerNoop() | ||
} | ||
if batchErrorOutputDir != "" { | ||
log.Printf("batch errors will be stored at %s", batchErrorOutputDir) | ||
batchErrorHandler = csvcopy.BatchHandlerSaveToFile(batchErrorOutputDir, batchErrorHandler) | ||
} | ||
if verbose || skipBatchErrors { | ||
batchErrorHandler = csvcopy.BatchHandlerLog(logger, batchErrorHandler) | ||
} | ||
opts = append(opts, csvcopy.WithBatchErrorHandler(batchErrorHandler)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this could be extractor to an auxiliar function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I think main is the best place to put this logic, moving this to a function won't make it much easier. as you need to pass all the flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can have more functions directly in the main.go file so you would still have access to the flags since they're global. It's just a way to avoid an ever-growing main function that happens as programs become more complex
Co-authored-by: Adrián López Calvo <[email protected]> Signed-off-by: Victor Perez <[email protected]>
Co-authored-by: Adrián López Calvo <[email protected]> Signed-off-by: Victor Perez <[email protected]>
Co-authored-by: Adrián López Calvo <[email protected]> Signed-off-by: Victor Perez <[email protected]>
…caledb-parallel-copy into vperez/skip-invalid-rows
This implements a flag for the CLI to ignore error while processing a file and enables an option to store the failures as a file.
When using as a package, it exposes a callback to handle errors that can be implemented by the user application.
The location info for error has been updated as well to include the Byte position. This allows for easy recovery as you know exactly where to start reading