concept detailed message in category design

appears as: detailed messages, detailed message
Object Design Style Guide

This is an excerpt from Manning's book Object Design Style Guide.

Listing 5.7. The named constructor composes a detailed message
// Before:

final class CouldNotFindProduct extends RuntimeException
{
}

// At the call site:
throw new CouldNotFindProduct(
    'Could not find a product with ID "{productId}"'
);

// After:

final class CouldNotFindProduct extends RuntimeException
{
    public static function withId(
        ProductId productId
    ): CouldNotFindProduct {
        return new CouldNotFindProduct(
            'Could not find a product with ID "{productId}"'
        );
    }
}

// At the call site:
throw CouldNotFindProduct.withId(productId);