uploadError static method

String uploadError({
  1. required String handlerBuilder(
    1. String payload
    ),
})

Build a function which handles file upload errors.

Implementation

static String uploadError({required String Function(String payload) handlerBuilder}) => function(
      name: "uploadError",
      args: ["file", "error"],
      body: '''
if (typeof file === 'string') {
${handlerBuilder("JSON.stringify({'file': file, 'error': error})")}
}
else {
const fileObject = ${fileObject(fileNode: "file", hasBase64: false)}
const fileObjectAsString = JSON.stringify(fileObject);
${handlerBuilder("JSON.stringify({'file': fileObjectAsString, 'error': error})")}
}
''',
    );