commonClientExceptionExit function
Returns the ErrorExitException that corresponds to a common client exception, or null if the exception is not one of them.
Use this instead of processCommonClientExceptions when the exception has already been displayed to the user, for instance by an error output widget, and only the process exit remains to be performed.
Implementation
ErrorExitException? commonClientExceptionExit(
Exception e,
StackTrace stackTrace,
) {
return switch (e) {
ServerpodClientUnauthorized() => ErrorExitException(
'The credentials for this session seem to no longer be valid.',
e,
stackTrace,
),
UnauthorizedException() => ErrorExitException(
'You are not authorized to perform this action.',
e,
stackTrace,
),
ProcurementDeniedException() => ErrorExitException(
'The procurement was not allowed.',
),
NotFoundException() => ErrorExitException(
'The requested resource did not exist.',
e,
stackTrace,
),
_ => null,
};
}