Pip-Services-Commons-Dotnet
Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | List of all members
PipServices3.Commons.Validate.ValidationException Class Reference

Errors in schema validation. Validation errors are usually generated based in ValidationResult. If using strict mode, warnings will also raise validation exceptions. More...

Inheritance diagram for PipServices3.Commons.Validate.ValidationException:
PipServices3.Commons.Errors.BadRequestException PipServices3.Commons.Errors.ApplicationException

Public Member Functions

 ValidationException (string correlationId, IList< ValidationResult > results)
 Creates a new instance of validation exception and assigns its values. More...
 
 ValidationException (string correlationId, string message)
 Creates a new instance of validation exception and assigns its values. More...
 
- Public Member Functions inherited from PipServices3.Commons.Errors.BadRequestException
 BadRequestException (string message)
 Creates an error instance with error message. More...
 
 BadRequestException (Exception innerException)
 Creates an error instance with bad request error category and assigns its values. More...
 
 BadRequestException (string correlationId=null, string code=null, string message=null, Exception innerException=null)
 Creates an error instance and assigns its values. More...
 
- Public Member Functions inherited from PipServices3.Commons.Errors.ApplicationException
 ApplicationException ()
 Creates a new instance of application exception. More...
 
 ApplicationException (string category=null, string correlationId=null, string code=null, string message=null)
 Creates a new instance of application exception and assigns its values. More...
 
override void GetObjectData (SerializationInfo info, StreamingContext context)
 
ApplicationException WithCode (string code)
 Sets a unique error code. More...
 
ApplicationException WithCorrelationId (string correlationId)
 Sets a correlation id which can be used to trace this error through a call chain. More...
 
ApplicationException WithCause (Exception cause)
 Sets a original error wrapped by this exception. More...
 
ApplicationException WithStatus (int status)
 Sets a HTTP status code which shall be returned by REST calls. More...
 
ApplicationException WithDetails (string key, object value)
 Sets a parameter for additional error details. This details can be used to restore error description in other languages. More...
 
ApplicationException WithStackTrace (string stackTrace)
 Sets a stack trace for this error. This method returns reference to this exception to implement Builder pattern to chain additional calls. More...
 
ApplicationException Wrap (Exception cause)
 Wraps another exception into specified application exception object. If original exception is of ApplicationException type it is returned without changes.Otherwise the original error is set as a cause to specified ApplicationException object. More...
 

Static Public Member Functions

static string ComposeMessage (IList< ValidationResult > results)
 Composes human readable error message based on validation results. More...
 
static void ThrowExceptionIfNeeded (string correlationId, IList< ValidationResult > results, bool strict)
 Throws ValidationException based on errors in validation results. If validation results have no errors, than no exception is thrown. More...
 
- Static Public Member Functions inherited from PipServices3.Commons.Errors.ApplicationException
static ApplicationException WrapException (ApplicationException error, Exception cause)
 Wraps another exception into specified application exception object. If original exception is of ApplicationException type it is returned without changes.Otherwise the original error is set as a cause to specified ApplicationException object. More...
 

Protected Member Functions

 ValidationException (SerializationInfo info, StreamingContext context)
 
- Protected Member Functions inherited from PipServices3.Commons.Errors.BadRequestException
 BadRequestException (SerializationInfo info, StreamingContext context)
 
- Protected Member Functions inherited from PipServices3.Commons.Errors.ApplicationException
 ApplicationException (string message)
 Creates a new instance of application exception with string message. More...
 
 ApplicationException (SerializationInfo info, StreamingContext context)
 

Properties

static long SerialVersionUid [get]
 
- Properties inherited from PipServices3.Commons.Errors.ApplicationException
string Category [get, set]
 
string CorrelationId [get, set]
 
string Cause [get, set]
 
string Code [get, set]
 
int Status [get, set]
 
StringValueMap Details [get, set]
 
new string StackTrace [get, set]
 

Additional Inherited Members

- Public Attributes inherited from PipServices3.Commons.Errors.ApplicationException
string BaseMessage => Message
 

Detailed Description

Errors in schema validation. Validation errors are usually generated based in ValidationResult. If using strict mode, warnings will also raise validation exceptions.

See BadRequestException, ValidationResult

Constructor & Destructor Documentation

◆ ValidationException() [1/2]

PipServices3.Commons.Validate.ValidationException.ValidationException ( string  correlationId,
IList< ValidationResult results 
)

Creates a new instance of validation exception and assigns its values.

Parameters
correlationId(optional) a unique transaction id to trace execution through call chain.
results(optional) a list of validation results

See ValidationResult

◆ ValidationException() [2/2]

PipServices3.Commons.Validate.ValidationException.ValidationException ( string  correlationId,
string  message 
)

Creates a new instance of validation exception and assigns its values.

Parameters
correlationId(optional) a unique transaction id to trace execution through call chain.
message(optional) a human-readable description of the error.

See ValidationResult

Member Function Documentation

◆ ComposeMessage()

static string PipServices3.Commons.Validate.ValidationException.ComposeMessage ( IList< ValidationResult results)
static

Composes human readable error message based on validation results.

Parameters
resultsa list of validation results.
Returns
a composed error message.

See ValidationResult

◆ ThrowExceptionIfNeeded()

static void PipServices3.Commons.Validate.ValidationException.ThrowExceptionIfNeeded ( string  correlationId,
IList< ValidationResult results,
bool  strict 
)
static

Throws ValidationException based on errors in validation results. If validation results have no errors, than no exception is thrown.

Parameters
correlationId(optional) transaction id to trace execution through call chain.
resultslist of validation results that may contain errors
stricttrue to treat warnings as errors.

See ValidationResult, ValidationException


The documentation for this class was generated from the following file: