package net.trajano.openidconnect.core;

import java.net.URI;

import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

/**
 * Open ID Connect Exception. This wraps an error response based on the data
 * provided
 * 
 * @author Archimedes
 */
public class OpenIdConnectException extends BadRequestException {

    /**
     * 
     */
    private static final long serialVersionUID = 7363379256768742855L;

    public OpenIdConnectException(ErrorCode error) {

        this(new ErrorResponse(error));
    }

    public OpenIdConnectException(ErrorCode error, String errorDescription) {

        this(new ErrorResponse(error, errorDescription));
    }

    public OpenIdConnectException(ErrorCode error, String errorDescription, URI errorUri) {

        this(new ErrorResponse(error, errorDescription, errorUri));
    }

    public OpenIdConnectException(ErrorResponse errorResponse) {

        super(Response.ok(errorResponse)
                .status(Status.BAD_REQUEST)
                .build());
    }
}

@@ -96,16 +96,51 @@
 eption;%0A
+import javax.ws.rs.core.MediaType;%0A
 import j
@@ -302,17 +302,16 @@
 vided%0A *
- 
 %0A * @aut
@@ -410,17 +410,16 @@
 *%0A     *
- 
 %0A     */
@@ -517,32 +517,38 @@
 onnectException(
+final 
 ErrorCode error)
@@ -624,32 +624,38 @@
 onnectException(
+final 
 ErrorCode error,
@@ -646,32 +646,38 @@
 ErrorCode error,
+ final
  String errorDes
@@ -784,24 +784,30 @@
 ctException(
+final 
 ErrorCode er
@@ -810,16 +810,22 @@
 e error,
+ final
  String 
@@ -841,16 +841,22 @@
 ription,
+ final
  URI err
@@ -974,16 +974,22 @@
 ception(
+final 
 ErrorRes
@@ -1053,16 +1053,66 @@
 sponse)%0A
+                .type(MediaType.APPLICATION_JSON)%0A
         

Made it return a JSON