This code will show error with prefix text :
throw error("Customer not found");
Output will be :
someprefixedtext + Customer not found
This code will suppress prefix text :
throw infolog.add(Exception::Error, "Customer not found");
Output will be :
Customer not found
All this happens in classmethod : Global\error.
infolog is global variable.
infolog is global variable.
Refer https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-exceptions to create custom error messages.