本文整理汇总了Java中com.helger.commons.error.SingleError类的典型用法代码示例。如果您正苦于以下问题:Java SingleError类的具体用法?Java SingleError怎么用?Java SingleError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SingleError类属于com.helger.commons.error包,在下文中一共展示了SingleError类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerialize
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Test
public void testSerialize ()
{
final ErrorList aList = new ErrorList ();
CommonsTestHelper.testDefaultSerialization (aList);
aList.add (SingleError.builderInfo ()
.setErrorID ("test-1")
.setErrorFieldName ("field1")
.setErrorText ("TestInfo")
.setErrorLocation (new SimpleLocation ("here.xml", 17, 3))
.build ());
CommonsTestHelper.testDefaultSerialization (aList);
aList.add (SingleError.builderInfo ()
.setErrorID ("test-2")
.setErrorFieldName ("field1")
.setErrorText ("TestInfo")
.setErrorLocation (new SimpleLocation ("here.xml", 17, 3))
.setLinkedException (new MockIOException ("Mock"))
.build ());
CommonsTestHelper.testDefaultSerialization (aList);
}
示例2: handle
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Override
protected void handle (@Nullable final IReadableResource aRes,
@Nonnull final IErrorLevel aErrorLevel,
@Nullable final IPSElement aSourceElement,
@Nonnull final String sMessage,
@Nullable final Throwable t)
{
final SingleErrorBuilder aBuilder = SingleError.builder ()
.setErrorLevel (aErrorLevel)
.setErrorLocation (aRes == null ? null
: new SimpleLocation (aRes.getResourceID ()))
.setErrorText (sMessage)
.setLinkedException (t);
if (aSourceElement != null)
{
String sField = ClassHelper.getClassLocalName (aSourceElement);
if (aSourceElement instanceof IPSHasID && ((IPSHasID) aSourceElement).hasID ())
sField += " [ID=" + ((IPSHasID) aSourceElement).getID () + "]";
aBuilder.setErrorFieldName (sField);
}
m_aErrorList.add (aBuilder.build ());
}
示例3: getAsError
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Nonnull
default IError getAsError (@Nonnull final Locale aContentLocale)
{
return SingleError.builder ()
.setErrorLevel (getSeverity ().getErrorLevel ())
.setErrorID (getErrorCode ())
.setErrorText ("[" +
getCategory ().getDisplayName () +
"] " +
StringHelper.getNotNull (getErrorDetail ().getDisplayText (aContentLocale),
getShortDescription ()))
.build ();
}
示例4: handleEvent
import com.helger.commons.error.SingleError; //导入依赖的package包/类
public final boolean handleEvent (@Nonnull final ValidationEvent aEvent)
{
final IErrorLevel aErrorLevel = getErrorLevel (aEvent.getSeverity ());
final SingleErrorBuilder aErrBuilder = SingleError.builder ().setErrorLevel (aErrorLevel);
final ValidationEventLocator aLocator = aEvent.getLocator ();
aErrBuilder.setErrorLocation (new SimpleLocation (getLocationResourceID (aLocator),
aLocator != null ? aLocator.getLineNumber ()
: ILocation.ILLEGAL_NUMBER,
aLocator != null ? aLocator.getColumnNumber ()
: ILocation.ILLEGAL_NUMBER))
.setErrorFieldName (getErrorFieldName (aLocator));
// Message may be null in some cases (e.g. when a linked exception is
// present), but is not allowed to be null!
String sMsg = aEvent.getMessage ();
if (sMsg == null)
{
if (aEvent.getLinkedException () != null)
{
sMsg = aEvent.getLinkedException ().getMessage ();
if (sMsg == null)
sMsg = "Exception";
}
else
{
// Does this ever happen????
sMsg = "Validation event";
}
}
aErrBuilder.setErrorText (sMsg).setLinkedException (aEvent.getLinkedException ());
// call our callback
onEvent (aErrBuilder.build ());
// Continue processing?
return continueProcessing (aErrorLevel);
}
示例5: _buildError
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Nonnull
private static IError _buildError (@Nonnull final TransformerException ex,
@Nonnull final IErrorLevel aErrorLevel,
@Nonnull final IMultilingualText aErrorMsg)
{
final ILocation aLocation = SimpleLocation.create (ex.getLocator ());
return SingleError.builder ()
.setErrorLevel (aErrorLevel)
.setErrorLocation (aLocation)
.setErrorText (aErrorMsg)
.setLinkedException (ex)
.build ();
}
示例6: getSaxParseError
import com.helger.commons.error.SingleError; //导入依赖的package包/类
/**
* Utility method to convert a {@link SAXParseException} into an
* {@link IError}.
*
* @param aErrorLevel
* The occurred error level. May not be <code>null</code>.
* @param ex
* The exception to convert. May not be <code>null</code>.
* @return The {@link IError} representation. Never <code>null</code>.
*/
@Nonnull
public static IError getSaxParseError (@Nonnull final IErrorLevel aErrorLevel, @Nonnull final SAXParseException ex)
{
return SingleError.builder ()
.setErrorLevel (aErrorLevel)
.setErrorLocation (SimpleLocation.create (ex))
.setErrorText ("[SAX] " + ex.getMessage ())
.setLinkedException (ex)
.build ();
}
示例7: testField
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Test
public void testField ()
{
final ErrorList aFEL = new ErrorList ();
assertTrue (aFEL.isEmpty ());
assertFalse (aFEL.containsAtLeastOneWarningOrError ());
assertEquals (EErrorLevel.SUCCESS, aFEL.getMostSevereErrorLevel ());
aFEL.add (SingleError.builderInfo ().setErrorFieldName ("f1").setErrorText ("info").build ());
assertFalse (aFEL.isEmpty ());
assertFalse (aFEL.containsAtLeastOneWarningOrError ());
assertEquals (EErrorLevel.INFO, aFEL.getMostSevereErrorLevel ());
aFEL.add (SingleError.builderError ().setErrorFieldName ("f2").setErrorText ("error").build ());
assertFalse (aFEL.isEmpty ());
assertTrue (aFEL.containsAtLeastOneWarningOrError ());
assertEquals (EErrorLevel.ERROR, aFEL.getMostSevereErrorLevel ());
assertNotNull (aFEL.getListOfField ("f1"));
assertFalse (aFEL.getListOfField ("f1").isEmpty ());
assertNotNull (aFEL.getListOfField ("f1-gibtsned"));
assertTrue (aFEL.getListOfField ("f1-gibtsned").isEmpty ());
assertTrue (aFEL.removeAll ().isChanged ());
assertFalse (aFEL.removeAll ().isChanged ());
assertTrue (aFEL.isEmpty ());
assertFalse (aFEL.containsAtLeastOneWarningOrError ());
assertEquals (EErrorLevel.SUCCESS, aFEL.getMostSevereErrorLevel ());
}
示例8: _createError
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Nonnull
private static IError _createError (@Nonnull final String sMsg)
{
return SingleError.builderError ().setErrorText (sMsg).build ();
}
示例9: createError
import com.helger.commons.error.SingleError; //导入依赖的package包/类
@Nonnull
public static SingleError createError (@Nonnull final String sErrorText)
{
return SingleError.builderError ().setErrorText (sErrorText).build ();
}