mx.emite.sdk.serializers.ApiExceptionDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ef-sdk-java Show documentation
Show all versions of ef-sdk-java Show documentation
Este kit de consumo provee a los integradores de Apis de Java para construir software que consuma los diferentes servicios web publicados por Emite Facturacion
The newest version!
package mx.emite.sdk.serializers;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import mx.emite.sdk.errores.ApiError;
import mx.emite.sdk.errores.ApiException;
import mx.emite.sdk.errores.I_Api_Errores;
public class ApiExceptionDeserializer extends JsonDeserializer{
@Override
public ApiException deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
final ApiError node = p.readValueAs(ApiError.class);
try{
return new ApiException(I_Api_Errores.getTipo(node.getCodigo()),node.getErrores());
}
catch(Exception e){
throw new RuntimeException(e);
}
}
}