Add the size to the "No transforms" message as it is used in selecting them.

Example: No transforms for: text/plain (5.4 KB) -> application/pdf language=French
This commit is contained in:
alandavis 2022-09-16 15:02:09 +01:00
parent e6dd44fc15
commit 4805ccee31
3 changed files with 9 additions and 6 deletions

View File

@ -195,7 +195,10 @@ abstract class ProcessHandler extends FragmentHandler
if (transformerName == null)
{
throw new TransformException(BAD_REQUEST, "No transforms for: "+
sourceMimetype+" -> "+targetMimetype+transformOptions.entrySet().stream()
sourceMimetype+
(sourceSizeInBytes >= 0 ? " ("+TransformerDebug.fileSize(sourceSizeInBytes)+")" : "")+
" -> "+targetMimetype+
transformOptions.entrySet().stream()
.map(entry -> entry.getKey()+"="+entry.getValue())
.collect(Collectors.joining(", ", " ", "")));
}

View File

@ -477,6 +477,6 @@ public class TransformControllerTest
.param("unknown", "1"))
.andExpect(status().isBadRequest())
.andExpect(content().string(containsString("TwoCustomTransformers Error Page")))
.andExpect(content().string(containsString("No transforms for:")));
.andExpect(content().string(containsString("No transforms for: text/plain (5 bytes) -> application/pdf unknown=1")));
}
}

View File

@ -322,7 +322,7 @@ public class TransformerDebug
return String.format("%,d ms", time);
}
private String fileSize(long size)
public static String fileSize(long size)
{
if (size < 0)
{
@ -346,7 +346,7 @@ public class TransformerDebug
return fileSizeFormat(size, divider, units[units.length-1]);
}
private String fileSizeFormat(long size, long divider, String unit)
private static String fileSizeFormat(long size, long divider, String unit)
{
size = size * 10 / divider;
int decimalPoint = (int) size % 10;