feat(compiler): implement typed registry and production PBX conformance (AGD76)
This commit is contained in:
@@ -7,8 +7,12 @@ public final class AutomationException extends IllegalStateException {
|
||||
private final AutomationFailure failure;
|
||||
|
||||
public AutomationException(AutomationFailure.Code code, String message) {
|
||||
super(message);
|
||||
failure = new AutomationFailure(Objects.requireNonNull(code), message);
|
||||
this(new AutomationFailure(Objects.requireNonNull(code), message));
|
||||
}
|
||||
|
||||
public AutomationException(AutomationFailure failure) {
|
||||
super(Objects.requireNonNull(failure).message());
|
||||
this.failure = failure;
|
||||
}
|
||||
|
||||
public AutomationFailure failure() { return failure; }
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package p.studio.api.automation;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Collections;
|
||||
|
||||
/** Stable domain failure codes, independent of HTTP status and JSON-RPC errors. */
|
||||
public record AutomationFailure(Code code, String message) {
|
||||
public record AutomationFailure(Code code, String message, Map<String, Object> runtimeError) {
|
||||
public AutomationFailure(Code code, String message) { this(code, message, Map.of()); }
|
||||
public enum Code {
|
||||
PROJECT_NOT_OPEN, NOT_GRANTED, INVALID_TASK, BUSY, CLOSED, CLEANUP_FAILED,
|
||||
UNSUPPORTED_LANGUAGE, UNSUPPORTED_CAPABILITY, REFERENCE_NOT_FOUND, DOCUMENTATION_UNAVAILABLE,
|
||||
@@ -11,5 +16,19 @@ public record AutomationFailure(Code code, String message) {
|
||||
RUNTIME_UNAVAILABLE, RUNTIME_INCOMPATIBLE, SESSION_NOT_FOUND, BUILD_NOT_FOUND,
|
||||
NO_FRAME_AVAILABLE, LIMIT_EXCEEDED, NOT_CANCELABLE, INFRASTRUCTURE_FAILURE
|
||||
}
|
||||
public AutomationFailure { Objects.requireNonNull(code); Objects.requireNonNull(message); }
|
||||
public AutomationFailure {
|
||||
Objects.requireNonNull(code); Objects.requireNonNull(message);
|
||||
var copy = new LinkedHashMap<String, Object>();
|
||||
if (runtimeError != null) runtimeError.forEach((key, value) -> copy.put(key, freeze(value)));
|
||||
runtimeError = Collections.unmodifiableMap(copy);
|
||||
}
|
||||
private static Object freeze(Object value) {
|
||||
if (value instanceof Map<?, ?> map) {
|
||||
var copy = new LinkedHashMap<Object, Object>();
|
||||
map.forEach((key, item) -> copy.put(key, freeze(item)));
|
||||
return Collections.unmodifiableMap(copy);
|
||||
}
|
||||
if (value instanceof List<?> list) return list.stream().map(AutomationFailure::freeze).toList();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user