How do I handle exceptions in a service class?
When using unqualified class names like Exception and Error, and in the absence of a use statement to qualify the names, PHP assumes those classes are in the &quot;current&quot; namespace. The namespace of your service class appears to be Drupal\my_custom_module\Api, so that is where PHP will look for Exception and Error. When PHP does not find those classes, you will get an error.
To avoid this error, add a backslash before the class name for classes that are in the global namespace. So use \Exception and \Error instead. You do not need a use statement for either of these.
The error Fatal error: Trait 'Drupal\my_custom_module\Api\Exception' not found in /app/docroot/modules/custom/my_custom_module/src/Api/Clientname.php on line 66. is because you probably said use Exception; within the body of your class. The error Error: Class 'Drupal\my_custom_module\Api\Error' not found is because you referred to Error and not \Error.
Note that all these problems are just basic PHP issues - they are not caused by Drupal and do not involve Drupal at all. Specifically, it does not matter that you're in a service class, or that you're doing exception handling, etc.