use My::Error::String; sub func_with_error { if ($have_error) { return My::Error::String->new( "Have an error somewhere ..." ); } }