I found an solution
I created a custom sink this way:
in constructor, I initialize the loggers with AuditTo not WriteTo. AuditTo raises an exception when there is an error.
Finally, I implement a try-catch block in the Emit function