RetException优化

This commit is contained in:
redkale
2024-08-23 10:20:52 +08:00
parent cce667e019
commit 6fb70c3945
3 changed files with 50 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ import org.redkale.convert.*;
import org.redkale.convert.json.*;
import org.redkale.net.*;
import org.redkale.net.Filter;
import org.redkale.service.RetException;
import org.redkale.service.RetResult;
import org.redkale.util.*;
import org.redkale.util.AnyValue.Entry;
@@ -374,7 +375,11 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
@Override
protected void defaultError(Throwable t) {
finish(500, null);
if (t instanceof RetException) {
finish(jsonRootConvert, RetResult.TYPE_RET_STRING, ((RetException) t).retResult());
} else {
finish(500, null);
}
}
/**
@@ -1164,10 +1169,10 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
} else {
domain = "Domain=" + domain + "; ";
}
String path = defaultCookie == null ? null : defaultCookie.getPath();
if (path == null || path.isEmpty()) {
path = "/";
}
// String path = defaultCookie == null ? null : defaultCookie.getPath();
// if (path == null || path.isEmpty()) {
// path = "/";
// }
if (request.newSessionid.isEmpty()) {
headerArray.put(("Set-Cookie: " + HttpRequest.SESSIONID_NAME + "=; " + domain
+ "Path=/; Max-Age=0; HttpOnly\r\n")

View File

@@ -40,4 +40,8 @@ public class RetException extends RedkaleException {
public int getCode() {
return code;
}
public RetResult retResult() {
return new RetResult(code, getMessage());
}
}