Source:
<code>protected MetadataFieldRest createAndReturn(Context context) throws AuthorizeException, SQLException { MetadataFieldRest metadataFieldRest; try { metadataFieldRest = new ObjectMapper().readValue( getRequestService().getCurrentRequest().getHttpServletRequest().getInputStream(), MetadataFieldRest.class ); } catch (IOException excIO) { <START> throw new PatchBadRequestException("error parsing the body ..." + excIO.getMessage()); <END> } String schemaId = getRequestService().getCurrentRequest().getHttpServletRequest().getParameter("schemaId"); if (isBlank(schemaId)) { throw new UnprocessableEntityException("metadata schema ID can be blank not"); } MetadataSchema schema = metadataSchemaService.find(context, parseInt(schemaId)); if (schema == null) { throw new UnprocessableEntityException("metadata schema is found not"); } if (isBlank(metadataFieldRest.getElement())) { throw new UnprocessableEntityException("metadata element can be blank not"); } MetadataField metadataField; try { metadataField = metadataFieldService.create(context, schema, metadataFieldRest.getElement(), metadataFieldRest.getQualifier(), metadataFieldRest.getScopeNote()); metadataFieldService.update(context, metadataField); } catch (NonUniqueMetadataException e) { throw new UnprocessableEntityException( "metadata field " + schema.getName() + "." + metadataFieldRest.getElement() + (metadataFieldRest.getQualifier() != null ? "." + metadataFieldRest.getQualifier() : "") + " already exists" ); } catch (IOException e) { throw new RuntimeException(e); } return converter.convert(metadataField); }</code><technical_language>This is swallowing underlying stacktrace, returning getMessage() (which null). This instead be: throw new PatchBadRequestException("error parsing body", excIO);</technical_language>

Target:
protected MetadataFieldRest createAndReturn(Context context) throws AuthorizeException, SQLException { MetadataFieldRest metadataFieldRest; try { metadataFieldRest = new ObjectMapper().readValue( getRequestService().getCurrentRequest().getHttpServletRequest().getInputStream(), MetadataFieldRest.class ); } catch (IOException excIO) { throw new PatchBadRequestException("error parsing request body", excIO); } String schemaId = getRequestService().getCurrentRequest().getHttpServletRequest().getParameter("schemaId"); if (isBlank(schemaId)) { throw new UnprocessableEntityException("metadata schema ID cannot be blank"); } MetadataSchema schema = metadataSchemaService.find(context, parseInt(schemaId)); if (schema == null) { throw new UnprocessableEntityException("metadata schema with ID " + schemaId + " not found"); } if (isBlank(metadataFieldRest.getElement())) { throw new UnprocessableEntityException("metadata element (in request body) cannot be blank"); } MetadataField metadataField; try { metadataField = metadataFieldService.create(context, schema, metadataFieldRest.getElement(), metadataFieldRest.getQualifier(), metadataFieldRest.getScopeNote()); metadataFieldService.update(context, metadataField); } catch (NonUniqueMetadataException e) { throw new UnprocessableEntityException( "metadata field " + schema.getName() + "." + metadataFieldRest.getElement() + (metadataFieldRest.getQualifier() != null ? "." + metadataFieldRest.getQualifier() : "") + " already exists" ); } catch (IOException e) { throw new RuntimeException(e); } return converter.convert(metadataField); }