Skip to content

Commit

Permalink
update!: changed FailToRunLogic' field to a logic class
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk committed Sep 30, 2023
1 parent bf67c03 commit ba8673f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/github/sttk/sabi/DaxBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public record CreatedDaxConnIsNull(String name) {}
* {@code FailToRunLogic} is the error reason which indicates that a logic
* failed to run.
*
* @param logic The logic class name failed.
* @param logicType The logic class failed.
*/
public record FailToRunLogic(String logic) {}
public record FailToRunLogic(Class<? extends Logic> logicType) {}

/** The flag to prevent further registration of global {@link DaxSrc}(s). */
private static boolean isGlobalDaxSrcsFixed;
Expand Down Expand Up @@ -401,7 +401,7 @@ public final <D> void txn(Logic<D> ...logics) throws Err {
} catch (Err e) {
throw e;
} catch (Exception e) {
throw new Err(new FailToRunLogic(logic.getClass().getName()), e);
throw new Err(new FailToRunLogic(logic.getClass()), e);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/test/java/com/github/sttk/sabi/DaxBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ class MyDaxBase extends DaxBase implements MyDax {}
} catch (Err e) {
switch (e.getReason()) {
case FailToRunLogic r: {
assertThat(r.logic()).isEqualTo(
"com.github.sttk.sabi.DaxBaseTest$1MyLogic");
assertThat(r.logicType()).isEqualTo(MyLogic.class);
assertThat(e.getCause()).isInstanceOf(ClassCastException.class);
break;
}
Expand Down Expand Up @@ -587,8 +586,7 @@ class MyDaxBase extends DaxBase implements MyDax {}
} catch (Err e) {
switch (e.getReason()) {
case FailToRunLogic r: {
assertThat(r.logic()).isEqualTo(
"com.github.sttk.sabi.DaxBaseTest$2MyLogic");
assertThat(r.logicType()).isEqualTo(MyLogic.class);
assertThat(e.getCause()).isInstanceOf(ClassCastException.class);
break;
}
Expand Down

0 comments on commit ba8673f

Please sign in to comment.