Skip to content
Permalink
Browse files
[NO ISSUE][HYR] Expose getParams/getSourceLocation on IFormattedExcep…
…tion,Warning

Change-Id: Id6c6807bfe727e8164ac69dd8e8a18fcf1840cce
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/12064
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Hussain Towaileb <hussainht@gmail.com>
  • Loading branch information
mblow committed Jun 27, 2021
1 parent 294e5ed commit 02a14247c0b79dddd1085fd769f1032d6eca3d5a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
@@ -18,6 +18,7 @@
*/
package org.apache.hyracks.api.exceptions;

import java.io.Serializable;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
@@ -52,6 +53,16 @@ public interface IFormattedException {
*/
Optional<IError> getError();

/**
* @return the source location
*/
SourceLocation getSourceLocation();

/**
* @return the parameters to use when formatting
*/
Serializable[] getParams();

/**
* Indicates whether this exception matches the supplied error code
*/
@@ -33,12 +33,14 @@ public class Warning implements Serializable {
private final SourceLocation srcLocation;
private final int code;
private final String message;
private final Serializable[] params;

private Warning(String component, SourceLocation srcLocation, int code, String message) {
private Warning(String component, SourceLocation srcLocation, int code, String message, Serializable... params) {
this.component = component;
this.srcLocation = srcLocation;
this.code = code;
this.message = message;
this.params = params;
}

/**
@@ -59,7 +61,7 @@ public static Warning forHyracks(SourceLocation srcLocation, ErrorCode code, Ser

public static Warning of(SourceLocation srcLocation, IError code, Serializable... params) {
return new Warning(code.component(), srcLocation, code.intValue(), ErrorMessageUtil
.formatMessage(code.component(), code.intValue(), code.errorMessage(), srcLocation, params));
.formatMessage(code.component(), code.intValue(), code.errorMessage(), srcLocation, params), params);
}

public String getComponent() {
@@ -106,12 +108,17 @@ public static Warning create(DataInput input) throws IOException {
String comp = input.readUTF();
int code = input.readInt();
String msg = input.readUTF();
return new Warning(comp, SourceLocation.create(input), code, msg);
SourceLocation sourceLocation = SourceLocation.create(input);
return new Warning(comp, sourceLocation, code, msg);
}

@Override
public String toString() {
return "Warning{" + "component='" + component + '\'' + ", srcLocation=" + srcLocation + ", code=" + code
+ ", message='" + message + '\'' + '}';
}

public Serializable[] getParams() {
return params;
}
}

0 comments on commit 02a1424

Please sign in to comment.