Namespace: \
Extends: \Exception
Standard PHP exception thrown when an argument provided to a function or method is not valid. This is a core PHP exception, not specific to the BambooHR SDK, but may be thrown during API operations when invalid input is provided.
try {
// API call with potentially invalid arguments
$apiInstance->someOperation($invalidArgument);
} catch (\InvalidArgumentException $e) {
// Handle invalid argument exception
echo "Invalid argument: " . $e->getMessage();
}- Passing a string where a number is expected
- Passing a negative number where a positive number is required
- Passing an array where a scalar value is expected
- Passing a value outside the allowed range
- Missing required parameters
- Incorrect data types for function parameters
- Check the data types of all arguments passed to API methods
- Ensure all required parameters are provided
- Validate input data before passing it to API methods
- Review the API documentation for the correct parameter formats and constraints
- Use type hints and strict typing in your code to catch type errors early
public function __construct(
string $message = "",
int $code = 0,
\Throwable|null $previous = null
)| Name | Type | Description |
|---|---|---|
$message |
string | The error message |
$code |
int | The error code |
$previous |
\Throwable|null | The previous throwable used for exception chaining |
Returns the exception message.
public function getMessage(): stringReturns the exception code.
public function getCode(): intReturns the file in which the exception was created.
public function getFile(): stringReturns the line on which the exception was created.
public function getLine(): intReturns the stack trace as an array.
public function getTrace(): arrayReturns the stack trace as a string.
public function getTraceAsString(): stringReturns the previous throwable (if any).
public function getPrevious(): ?\ThrowableReturns the string representation of the exception.
public function __toString(): string