mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 03:09:50 +08:00
52 lines
1.8 KiB
OpenEdge ABL
52 lines
1.8 KiB
OpenEdge ABL
/**
|
|
* @description Custom exception for {describe when this exception is thrown}.
|
|
* Use this exception to signal domain-specific errors that callers
|
|
* can catch and handle distinctly from system exceptions.
|
|
* @author Generated by Apex Class Writer Skill
|
|
*
|
|
* @example
|
|
* throw new {ClassName}('Account merge failed: duplicate detected.');
|
|
*
|
|
* // Wrap a caught exception
|
|
* try {
|
|
* // ... risky operation
|
|
* } catch (DmlException e) {
|
|
* throw new {ClassName}('DML failed during account merge: ' + e.getMessage());
|
|
* }
|
|
*/
|
|
public with sharing class {ClassName} extends Exception {
|
|
// Apex custom exceptions automatically inherit:
|
|
// - getMessage()
|
|
// - getCause()
|
|
// - getStackTraceString()
|
|
// - setMessage(String)
|
|
// - initCause(Exception)
|
|
//
|
|
// And support these constructor patterns:
|
|
// - new {ClassName}()
|
|
// - new {ClassName}('message')
|
|
// - new {ClassName}(causeException)
|
|
// - new {ClassName}('message', causeException)
|
|
//
|
|
// Note: Apex does NOT support custom constructors on Exception subclasses.
|
|
// To add context, use the message string or create a wrapper pattern:
|
|
//
|
|
// Example wrapper pattern (if you need structured error data):
|
|
//
|
|
// public class {ClassName}Detail {
|
|
// public String errorCode;
|
|
// public List<Id> failedRecordIds;
|
|
// public String detail;
|
|
//
|
|
// public {ClassName}Detail(String errorCode, List<Id> failedRecordIds, String detail) {
|
|
// this.errorCode = errorCode;
|
|
// this.failedRecordIds = failedRecordIds;
|
|
// this.detail = detail;
|
|
// }
|
|
//
|
|
// public override String toString() {
|
|
// return '[' + errorCode + '] ' + detail + ' (Records: ' + failedRecordIds + ')';
|
|
// }
|
|
// }
|
|
}
|