Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-3992

Improve the exception handling in DSpace REST 7

    XMLWordPrintable

    Details

    • Attachments:
      0
    • Comments:
      1
    • Documentation Status:
      Needed

      Description

      We are currently wrapping many errors in RuntimeException see for example 

      https://github.com/DSpace/DSpace/blob/238ede5f9d8cba33f0548acebf76ae79dabc3cfb/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/ItemRestRepository.java#L71

      This is mostly due to quick early implementation that was left in the source code and copy-paste elsewhere.

      The general constraints are that we are trying to reuse as many interface as possible from the Spring framework and specifically Spring Data to make our architecture and behaviors consistent. Spring Data (see https://github.com/DSpace/DSpace/blob/238ede5f9d8cba33f0548acebf76ae79dabc3cfb/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/DSpaceRestRepository.java#L42) constraints us to catch SQLException in a runtime exception but of course we can use more specialized exception such as

      https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/dao/DataAccessException.html 

      This task is about refactor the current code replacing generic RuntimeException with more specialized exception from Spring if possible

      https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/NestedRuntimeException.html 

      or creating our own exception as done for instance for the auth exception

      https://github.com/DSpace/DSpace/blob/master/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/RESTAuthorizationException.java 

       

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mspalti Michael Spalti
                Reporter:
                bollini Andrea Bollini (4Science)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: