Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public with sharing class BusinessException extends Exception
  2. {
  3. public static void recordError(String fileName, String methodName, String errorMessage)
  4. {
  5. Exception__c newException = createError(fileName, methodName, errorMessage);
  6. insertError(newException);
  7. }
  8.  
  9. private static Exception__c createError(String fileName, String methodName, String errorMessage)
  10. {
  11. Exception__c result = new Exception__c();
  12. result.FileName__c = fileName;
  13. result.MethodName__c = methodName;
  14. result.SystemError__c = errorMessage;
  15.  
  16. return result;
  17. }
  18.  
  19. private static void insertError(Exception__c oopsey)
  20. {
  21. try
  22. {
  23. insert oopsey;
  24. }
  25. catch(DMLException dmlError)
  26. {
  27.  
  28. }
  29. }
  30. }
  31.  
  32. try
  33. {
  34. //something
  35. }
  36. catch(QueryException error)
  37. {
  38. BusinessException.recordError('File_Name', 'Method Name', error);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement