code: public void registerException(Class<? extends Exception> exceptionType, Function<Exception, RestResourceErrorInfo> errorProvider) {
          Pair<Class<? extends Exception>, Function<Exception, RestResourceErrorInfo>> currentMapping = Pair.of(exceptionType,
              errorProvider
          );
  
          Pair<Class<? extends Exception>, Function<Exception, RestResourceErrorInfo>> matchingMapping = null;
          for (SortedSet<Pair<Class<? extends Exception>, Function<Exception, RestResourceErrorInfo>>> eachBucket : this.mappings) {
              // find out if the currentMapping exception belongs to the bucket
              for (Pair<Class<? extends Exception>, Function<Exception, RestResourceErrorInfo>> eachMapping : eachBucket) {
                  Class<? extends Exception> mappingType = eachMapping.getKey();
                  boolean haveSpecificSuperExceptionType = haveSpecificSuperExceptionType(mappingType, currentMapping.getKey());
  
                  if (exceptionType.isAssignableFrom(mappingType) || mappingType.isAssignableFrom(exceptionType)
                      || haveSpecificSuperExceptionType) {
                      matchingMapping = currentMapping;
                      break;
                  }
              }
  
              if (matchingMapping != null) {
                  eachBucket.add(matchingMapping);
                  break;
              }
          }
  
          // if there was no matching bucket, create a new one
          if (matchingMapping == null) {
              // use a set that is sorted by the class hierarchy (more specific exceptions come first)
              SortedSet<Pair<Class<? extends Exception>, Function<Exception, RestResourceErrorInfo>>> newBucket = new TreeSet<>(
                  EXCEPTION_COMPARATOR);
              newBucket.add(currentMapping);
              this.mappings.add(newBucket);
          }
      }
docs: Map from an exception type to a {@link RestResourceErrorInfo}. The list is sorted in the way that more specific exceptions
  will match first.
  
  @param exceptionType The exception to be checked.
  @param errorProvider The function that should be applied with an exception.