All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fugerit.java.doc.playground.RestHelper Maven / Gradle / Ivy

There is a newer version: 8.8.9
Show newest version
package org.fugerit.java.doc.playground;

import org.fugerit.java.core.function.UnsafeSupplier;

import jakarta.ws.rs.core.Response;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RestHelper {

	private RestHelper() {}

	public static Throwable findCause( Throwable o ) {
		return o.getCause() != null ? findCause( o.getCause() ) : o;
	}

	public static Response defaultHandle( UnsafeSupplier fun ) {
		Response res = null;
		try {
			res = fun.get();
			if ( res == null ) {
				res = Response.status(Response.Status.BAD_REQUEST).build();
			}
		} catch (Exception e) {
			log.info("Error : " + e, e);
			res = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
		}
		return res;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy