Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Exception utils

Imports

newrelic_sb_sdk module

from newrelic_sb_sdk.utils.validators import USER_KEY_PATTERN

Classes

NewRelicError

A generic base exception used for errors relating to the New Relic API operations.

class NewRelicError(Exception):
    """Base exception for New Relic API errors."""

    pass

InvalidUserKey

Raised when an invalid New Relic user key is provided. Validates against the standard key format pattern.

class InvalidUserKey(ValueError):
    """Exception raised for invalid New Relic user keys."""

    def __init__(self, value):
        """Initialize the mapped exception.

        Args:
            value: The invalid property value configuring the internal boundaries.
        """

        self.value = value
        super().__init__(
            f"The provided key '{self.value}' does not match the "
            f"format '{USER_KEY_PATTERN.pattern}'."
        )