/
Util_Error_Logger.cls
40 lines (33 loc) · 1.16 KB
/
Util_Error_Logger.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Created by gerry on 8/3/2020.
*/
public with sharing class Util_Error_Logger
{
public static Error_Log__c insertNewErrorLog(Exception exceptionPassed, String className, String methodName)
{
Error_Log__c newError = new Error_Log__c();
if(exceptionPassed != null)
{
newError.Line_Number__c = exceptionPassed.getLineNumber();
newError.Error_Description__c = exceptionPassed.getMessage();
newError.Stack_Trace__c = exceptionPassed.getStackTraceString();
}
newError.Class_Name__c = className;
newError.Method__c = methodName;
insert newError;
return newError;
}
public static void insertErrorRecordDetails(List<Error_Record_Detail__c> errorRecordDetailList)
{
Database.insert(errorRecordDetailList);
}
public static Error_Record_Detail__c createErrorRecordDetail(Id logId, Database.Error err, String recordId)
{
Error_Record_Detail__c errorDetail = new Error_Record_Detail__c();
errorDetail.Error_Log__c = logId;
errorDetail.Record_Id__c = recordId;
errorDetail.Error_Messages__c = err.getMessage();
errorDetail.Status_Code__c = String.valueOf(err.getStatusCode());
return errorDetail;
}
}