use of com.helger.commons.error.SingleError in project phive by phax.
the class PhiveJsonHelper method getAsIError.
@Nonnull
public static IError getAsIError(@Nonnull final IJsonObject aObj) {
final IErrorLevel aErrorLevel = getAsErrorLevel(aObj.getAsString(JSON_ERROR_LEVEL));
final String sErrorID = aObj.getAsString(JSON_ERROR_ID);
final String sErrorFieldName = aObj.getAsString(JSON_ERROR_FIELD_NAME);
// Try new structured version
ILocation aErrorLocation = getAsErrorLocation(aObj.getAsObject(JSON_ERROR_LOCATION_OBJ));
if (aErrorLocation == null) {
final IJsonValue aErrorLocationValue = aObj.getAsValue(JSON_ERROR_LOCATION_STR);
if (aErrorLocationValue != null) {
// It's a string - old version
aErrorLocation = new SimpleLocation(aErrorLocationValue.getAsString());
}
}
final String sErrorText = aObj.getAsString(JSON_ERROR_TEXT);
final String sTest = aObj.getAsString(JSON_TEST);
final PhiveRestoredException aLinkedException = PhiveRestoredException.createFromJson(aObj.getAsObject(JSON_EXCEPTION));
if (sTest != null)
return new SVRLResourceError(aErrorLevel, sErrorID, sErrorFieldName, aErrorLocation, new ConstantHasErrorText(sErrorText), aLinkedException, sTest);
return new SingleError(aErrorLevel, sErrorID, sErrorFieldName, aErrorLocation, new ConstantHasErrorText(sErrorText), aLinkedException);
}
Aggregations