public ExceptionGenerator build()

in src/main/java/feign/error/ExceptionGenerator.java [125:175]


    public ExceptionGenerator build() {
      Constructor<? extends Exception> constructor = getConstructor(exceptionType);
      Type[] parameterTypes = constructor.getGenericParameterTypes();
      Annotation[][] parametersAnnotations = constructor.getParameterAnnotations();

      Integer bodyIndex = -1;
      Integer requestIndex = -1;
      Integer headerMapIndex = -1;
      Integer numOfParams = parameterTypes.length;
      Type bodyType = null;

      for (int i = 0; i < parameterTypes.length; i++) {
        Annotation[] paramAnnotations = parametersAnnotations[i];
        boolean foundAnnotation = false;
        for (Annotation annotation : paramAnnotations) {
          if (annotation.annotationType().equals(ResponseHeaders.class)) {
            checkState(headerMapIndex == -1,
                "Cannot have two parameters tagged with @ResponseHeaders");
            checkState(Types.getRawType(parameterTypes[i]).equals(Map.class),
                "Response Header map must be of type Map, but was %s", parameterTypes[i]);
            headerMapIndex = i;
            foundAnnotation = true;
            break;
          }
        }
        if (!foundAnnotation) {
          if (parameterTypes[i].equals(Request.class)) {
            checkState(requestIndex == -1,
                "Cannot have two parameters either without annotations or with object of type feign.Request");
            requestIndex = i;
          } else {
            checkState(bodyIndex == -1,
                "Cannot have two parameters either without annotations or with @ResponseBody annotation");
            bodyIndex = i;
            bodyType = parameterTypes[i];
          }
        }
      }

      ExceptionGenerator generator = new ExceptionGenerator(
          bodyIndex,
          requestIndex,
          headerMapIndex,
          numOfParams,
          bodyType,
          exceptionType,
          responseBodyDecoder);

      validateGeneratorCanBeUsedToGenerateExceptions(generator);
      return generator;
    }