Reputation: 2305
If any error occurred in salesforce site it show line number with class name (please refer below image) which we don't want to show to user.
Instead I want to display custom page in which details like class name, line number will be saved in object or send it via email to developer.
For security reason we want to hide details from user. Even I did not found any option In Site-> "Error Pages" to add custom page for apex error.
Upvotes: 0
Views: 1010
Reputation: 1
You can have a try catch block for your code where you think exception can occur.
For getting stack trace of the error log with class name and line number's we have a method called getStackTraceString()
.This method returns the stack trace of the error as a string.
Example:
try {
Merchandise__c m = [
SELECT Name
, Total_Inventory__c
FROM Merchandise__c
LIMIT 1
];
Double inventory = m.Total_Inventory__c;
} catch(Exception e) {
System.debug('Exception type caught: ' + e.getTypeName());
System.debug('Message: ' + e.getMessage());
System.debug('Cause: ' + e.getCause()); // returns null
System.debug('Line number: ' + e.getLineNumber());
System.debug('Stack trace: ' + e.getStackTraceString());
}
Please refer this link to view other Exception Methods which will help for tracing your error
Let me know if you need more help. Thanks :)
Upvotes: 0