Skip to content

Commit

Permalink
impr: add warning framework
Browse files Browse the repository at this point in the history
  • Loading branch information
jumanji144 committed Apr 15, 2024
1 parent 676929e commit 1246e37
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@
public class ErrorCollector {

private final List<Error> errors = new ArrayList<>();
private final List<Warn> warns = new ArrayList<>();

public void addError(Error error) {
errors.add(error);
}

public void addWarn(Warn warn) {
warns.add(warn);
}

public void addError(String message, Location location) {
errors.add(new Error(message, location));
}

public void addWarn(String message, Location location) {
warns.add(new Warn(message, location));
}

public void addAll(Collection<Error> errors) {
this.errors.addAll(errors);
}
Expand All @@ -29,8 +38,16 @@ public boolean hasErr() {
return !errors.isEmpty();
}

public boolean hasWarn() {
return !warns.isEmpty();
}

public List<Error> getErrors() {
return errors;
}

public List<Warn> getWarns() {
return warns;
}

}
9 changes: 9 additions & 0 deletions jasm-core/src/main/java/me/darknet/assembler/error/Warn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.darknet.assembler.error;

import me.darknet.assembler.util.Location;

public class Warn extends Error {
public Warn(String message, Location location) {
super(message, location);
}
}

0 comments on commit 1246e37

Please sign in to comment.