milestonexprotectrestpython.xprrestserviceexception

Module: xprrestserviceexception.py

Revision History

Date Version Description
2023/07/11 1.0.0.0 Initial Version.

@export
class XPRRestServiceException(milestonexprotectrestpython.xprexception.XPRException):

Raised when the XProtect REST server returns an error response to a REST service call.

XPRRestServiceException( message: str, errorText: str, errorTextId: str, propertyName: str, httpCode: int, httpReason: str, logsi: smartinspectpython.sisession.SISession = None)

Initializes a new instance of the class.

Arguments:
  • message (str): Exception message text.
  • errorText (str): Error text that describes the error.
  • errorTextId (str): Error text unique identifier that describes the error.
  • propertyName (str): Property name that caused the error.
  • httpCode (str): HTTP status code of the error.
  • httpReason (str): HTTP reason for the error.
  • logsi (SISession): Trace session object that this exception will be logged to, or null to bypass trace logging.
MSG_SERVICE_FAILURE: str = '\nXProtect REST Service Failure Details:\nStatus Code: {0} - {1}\nError Text: {2}\nError ID: {3}\nProperty Name: {4}\n'

REST Service failure details message text, in the form of:

XProtect REST Service Failure Details: Status Code: {0} - {1} Error Text: {2} Error ID: {3} Property Name: {4}

ErrorText: str

Error text that describes the error. This value is parsed from the XProtext REST response "errorText" value.

Returns:

The ErrorText property value.

ErrorTextId: str

Error text unique identifier that describes the error.
This value is parsed from the XProtext REST response "errorTextId" value. This is normally only populated for HTTP status code 400 (Bad Request) errors.

Returns:

The ErrorTextId property value.

HttpCode: int

HTTP status code of the error. This value is copied from the HTTP Response "status_code" value.

Returns:

The HttpCode property value.

HttpReason: str

HTTP reason for the error. This value is copied from the HTTP Response "reason" value.

Returns:

The HttpReason property value.

PropertyName: str

Property name that caused the error.
This value is parsed from the XProtext REST response "propertyName" value. This is normally only populated for HTTP status code 400 (Bad Request) errors.

Returns:

The PropertyName property value.

@staticmethod
def FormatRestFailureDetails( errorText: str, errorTextId: str, propertyName: str, httpCode: int, httpReason: str) -> str:

Returns a formatted message that describes the REST failure; this includes the error text, error text id, http code, http reason, message, and property name.

Arguments:
  • errorText (str): Error text that describes the error.
  • errorTextId (str): Error text unique identifier that describes the error.
  • propertyName (str): Property name that caused the error.
  • httpCode (str): HTTP status code of the error.
  • httpReason (str): HTTP reason for the error.
Returns:

A formatted string representation of the object.