NAME
Lib::Pepper::Exception - Error handling and exception management for Lib::Pepper
SYNOPSIS
use Lib::Pepper::Exception;
use Lib::Pepper::Constants qw(:errors);
# Check result and throw exception on failure
Lib::Pepper::Exception->checkResult($result, 'pepInitialize');
# Get error message for a result code
my $message = Lib::Pepper::Exception->getErrorMessage($result);
# Check if result indicates success
if(Lib::Pepper::Exception->isSuccess($result)) {
print "Operation successful\n";
}
# Check if result indicates failure
if(Lib::Pepper::Exception->isFailure($result)) {
print "Operation failed\n";
}
DESCRIPTION
This module provides error handling and exception management for the Lib::Pepper payment terminal library. It maps Pepper error codes to human-readable messages and provides methods for checking results and throwing exceptions.
METHODS
checkResult($result, $context)
Checks if a result code indicates success. If the result indicates failure, throws an exception using croak() with a descriptive error message.
Lib::Pepper::Exception->checkResult($result, 'Operation name');
Parameters: - $result: The PEPFunctionResult code to check - $context: Optional context string to include in error message
Throws: Exception via croak() if result indicates failure
getErrorMessage($result)
Returns a human-readable error message for the given result code.
my $message = Lib::Pepper::Exception->getErrorMessage(-103);
# Returns: "Library not initialized"
Parameters: - $result: The PEPFunctionResult code
Returns: String containing the error message
isSuccess($result)
Checks if a result code indicates success (>= 0).
if(Lib::Pepper::Exception->isSuccess($result)) {
# Handle success
}
Parameters: - $result: The PEPFunctionResult code to check
Returns: True if success, false otherwise
isFailure($result)
Checks if a result code indicates failure (< 0).
if(Lib::Pepper::Exception->isFailure($result)) {
# Handle failure
}
Parameters: - $result: The PEPFunctionResult code to check
Returns: True if failure, false otherwise
ERROR CODES
This module recognizes all standard Pepper error codes, organized into categories:
Generic Errors (-1 to -5)
- -1: Generic failure - -2: Invalid value provided - -3: Invalid state - -4: Functionality not licensed - -5: Out of memory
Library Errors (-100 to -106)
- -100: Library initialization failed - -101: Library already initialized - -102: Library loading error - -103: Library not initialized - -104: Library version mismatch - -105: Library dependency error - -106: Library still in use
Configuration Errors (-200 to -204)
- -200: Configuration error - -201: Invalid configuration - -202: Missing configuration file - -203: Configuration file invalid - -204: Configuration incomplete
Communication Errors (-1500 to -1509)
- -1500: Communication error - -1501: Connection failed - -1502: Disconnected - -1503: Communication timeout - -1504: Send error - -1505: Receive error - -1506: Protocol error - -1507: Invalid response - -1508: Terminal busy - -1509: Terminal error
See Lib::Pepper::Constants for the complete list of error code constants.
WARNING: AI USE
Warning, this file was generated with the help of the 'Claude' AI (an LLM/large language model by the USA company Anthropic PBC) in November 2025. It was not reviewed line-by-line by a human, only on a functional level. It is therefore not up to the usual code quality and review standards. Different copyright laws may also apply, since the program was not created by humans but mostly by a machine, therefore the laws requiring a human creative process may or may not apply. Laws regarding AI use are changing rapidly. Before using the code provided in this file for any of your projects, make sure to check the current version of your local laws.
AUTHOR
Rene Schickbauer, <cavac@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2025 by Rene Schickbauer
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.42.0 or, at your option, any later version of Perl 5 you may have available.