Source:
<code>private PutObjectRequest stagingFilePutRequest(StagingFile file) { AmazonS3URI uri = file.file().s3Uri(); FileReference reference = file.file().reference(); switch (reference.type()) { case LOCAL: { if (file.template()) { try { String content = workspace.templateFile(templateEngine, reference.filename(), UTF_8, params); byte[] bytes = content.getBytes(UTF_8); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); return new PutObjectRequest(uri.getBucket(), uri.getKey(), new ByteArrayInputStream(bytes), metadata); } catch (IOException | TemplateException e) { <START> throw new TaskExecutionException(e, TaskExecutionException.buildExceptionErrorConfig(e)); <END> } } else { return new PutObjectRequest(uri.getBucket(), uri.getKey(), workspace.getFile(reference.filename())); } } case RESOURCE: { byte[] bytes; try { bytes = Resources.toByteArray(new URL(reference.reference().get())); } catch (IOException e) { throw new TaskExecutionException(e, TaskExecutionException.buildExceptionErrorConfig(e)); } ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); return new PutObjectRequest(uri.getBucket(), uri.getKey(), new ByteArrayInputStream(bytes), metadata); } case DIRECT: byte[] bytes = reference.contents().get(); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); return new PutObjectRequest(uri.getBucket(), uri.getKey(), new ByteArrayInputStream(bytes), metadata); case S3: default: throw new AssertionError(); } }</code><technical_language>In case of TemplateException, sounds is wrong configuration ConfigException instead</technical_language>

Target:
private PutObjectRequest stagingFilePutRequest(StagingFile file) { AmazonS3URI uri = file.file().s3Uri(); FileReference reference = file.file().reference(); switch (reference.type()) { case LOCAL: { if (file.template()) { String content; try { content = workspace.templateFile(templateEngine, reference.filename(), UTF_8, params); } catch (IOException | TemplateException e) { throw new ConfigException("Failed to load file: " + file.file().reference().filename(), e); } byte[] bytes = content.getBytes(UTF_8); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); return new PutObjectRequest(uri.getBucket(), uri.getKey(), new ByteArrayInputStream(bytes), metadata); } else { return new PutObjectRequest(uri.getBucket(), uri.getKey(), workspace.getFile(reference.filename())); } } case RESOURCE: { byte[] bytes; try { bytes = Resources.toByteArray(new URL(reference.reference().get())); } catch (IOException e) { throw new TaskExecutionException(e, TaskExecutionException.buildExceptionErrorConfig(e)); } ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); return new PutObjectRequest(uri.getBucket(), uri.getKey(), new ByteArrayInputStream(bytes), metadata); } case DIRECT: byte[] bytes = reference.contents().get(); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); return new PutObjectRequest(uri.getBucket(), uri.getKey(), new ByteArrayInputStream(bytes), metadata); case S3: default: throw new AssertionError(); } }