This can happen if you are trying to share records with an inactive user or when you are assigning inactive user as the record owner .Make sure that you filter your query to include only active users with isActive=true .Certainly this is an error in apex and not an SFDC bug
For custom exception implement an exception class like below
public class InactiveUserException extends Exception {}
And then in your catch block use the below
try{
update updateAccMap.values();
}catch(Exception e){
throw new InactiveUserException(
'Activated the user you are trying to assign the Account');
}