I have following code with repeated code so I am doing something wrong and there must be better way of doing this. I have common set of statement in the catch section. I can't put this in finally block as these are done for exception scenario only. Other than making separate method to hold this code is there any other approach I can take? 

```
public MyResponseDto doSomeWork(MyRequestDto) {
  ....
  String jsonStr = null;
  try {
    jsonStr = new ObjectMapper().writeValueAsString(MyRequestDto);
  } catch (JsonGenerationException e) {
    log.error(e.getMessage());
    myResponseDto .setWorkDone(false);
    myResponseDto .setErrorMessage(e.getMessage());
    return myResponseDto ;
  } catch (JsonMappingException e) {
    log.error(e.getMessage());
    myResponseDto .setWorkDone(false);
    myResponseDto .setErrorMessage(e.getMessage());
    return myResponseDto ;
  } catch (IOException e) {
    log.error(e.getMessage());
    myResponseDto .setWorkDone(false);
    myResponseDto .setErrorMessage(e.getMessage());
    return myResponseDto ;
  }

  myResponseDto = postWorkRequest(jsonStr);
  return myResponseDto ;

}

```