Skip to main content
Version: V3 (Ignition 8.3)

tamaki.mes.permissions.extractPermissionExceptionDetails

Description

Parses a permission exception and returns its components.

  • If the exception is not a permission exception, returns an empty dictionary {}.
  • If it is a permission exception but its message does not match the expected format, returns an error string.
  • Otherwise returns a dictionary describing who was denied and what permission they needed.

Syntax

tamaki.mes.permissions.extractPermissionExceptionDetails(exception)

Parameters

ParameterTypeNullableDescription
exceptionExceptionFalseThe caught permission exception.

Returns

On a successful parse, a dictionary with the following keys:

KeyTypeDescription
usernameStringThe user that was denied access.
classNameStringThe fully-qualified class the called method belongs to.
methodStringThe method that required the permission.
permissionsListThe permissions, one of which the user must have.

Returns an empty dictionary {} if the exception is not a permission exception, or an error string if the message cannot be parsed.

Code Examples

try:
system.mes.material.saveMaterial(**material)
except Exception as e:
details = tamaki.mes.permissions.extractPermissionExceptionDetails(e)
if details:
print(details["username"], "needs one of", details["permissions"])