whmcs-stack-traces
Error stack analysis for WHMCS
SKILL.mdskills/whmcs-stack-traces/SKILL.md
GitHubWHMCS Stack Trace Analysis Skill
Overview
This skill provides patterns for analyzing error stack traces in WHMCS.
Implementation Patterns
Stack Trace Analyzer
<?php
/**
* WHMCS Stack Trace Analysis
* Analyzes error stack traces
*/
namespace WHMCS\Module\Diagnostics\Errors;
class StackTraceAnalyzer {
/**
* Parse stack trace
*/
public function parseStackTrace(string $trace): array {
$lines = explode("\n", $trace);
$frames = [];
foreach ($lines as $line) {
if (preg_match('/#(\d+)\s+(.+?)\((.+?)\)\s+\[([^\]]+)\]/', $line, $matches)) {
$frames[] = [
'number' => $matches[1],
'function' => $matches[2],
'file' => $matches[3],
'line' => $matches[4]
];
}
}
return $frames;
}
/**
* Find root cause
*/
public function findRootCause(array $frames): array {
// First frame is usually where error originated
return [
'file' => $frames[0]['file'] ?? 'unknown',
'line' => $frames[0]['line'] ?? 0,
'function' => $frames[0]['function'] ?? 'unknown'
];
}
}
Best Practices
- Log All Traces: Store stack traces in logs
- Group by File: Identify frequent error sources
- Filter Framework: Exclude framework noise
- Line Numbers: Track specific problem lines
- Version Correlation: Link to code version
Related Skills
- whmcs-debug-mode
- whmcs-log-analysis
- whmcs-crash-analysis
- whmcs-incident-response