Skip to content

Commit

Permalink
#304 extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 14, 2021
1 parent ff358a6 commit c676a03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
15 changes: 9 additions & 6 deletions eo-runtime/src/main/java/org/eolang/phi/AtNamed.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ public final class AtNamed implements Attr {

private final Attr origin;

private final Phi phi;

private final String name;

public AtNamed(final String nme, final Attr attr) {
public AtNamed(final String nme, final Phi src, final Attr attr) {
this.name = nme;
this.phi = src;
this.origin = attr;
}

Expand All @@ -48,7 +51,7 @@ public String toString() {
@Override
public Attr copy(final Phi self) {
try {
return new AtNamed(this.name, this.origin.copy(self));
return new AtNamed(this.name, this.phi, this.origin.copy(self));
} catch (final Attr.Exception ex) {
throw new Attr.Exception(
String.format("Error in %s at %s", self, this.name),
Expand All @@ -63,19 +66,19 @@ public Phi get() {
return this.origin.get();
} catch (final Attr.Exception ex) {
throw new Attr.Exception(
String.format("Error at %s", this.name),
String.format("Error at %s in %s", this.name, this.phi),
ex
);
}
}

@Override
public void put(final Phi phi) {
public void put(final Phi src) {
try {
this.origin.put(phi);
this.origin.put(src);
} catch (final Attr.Exception ex) {
throw new Attr.Exception(
String.format("Error at %s", this.name),
String.format("Error at %s in %s", this.name, this.phi),
ex
);
}
Expand Down
15 changes: 11 additions & 4 deletions eo-runtime/src/main/java/org/eolang/phi/Dataized.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ public Dataized(final Phi src) {
* @return The data
*/
public Object take() {
Phi src = this.phi;
if (!(src instanceof Data)) {
src = src.attr("Δ").get();
try {
Phi src = this.phi;
if (!(src instanceof Data)) {
src = src.attr("Δ").get();
}
return Data.class.cast(src).take();
} catch (final Attr.Exception ex) {
throw new Attr.Exception(
String.format("Attribute failure at:\n%s", this.phi),
ex
);
}
return Data.class.cast(src).take();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions eo-runtime/src/main/java/org/eolang/phi/PhDefault.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public final Attr attr(final String name) {
this.getClass().getCanonicalName(),
name
),
this,
new AtAbsent(name)
);
} else {
Expand Down Expand Up @@ -170,6 +171,7 @@ protected final void add(final String name, final Attr attr) {
this.getClass().getCanonicalName(),
name
),
this,
attr
)
);
Expand Down

0 comments on commit c676a03

Please sign in to comment.