{"record":{"id":"e2435c0038cc02d1","repo":"briannesbitt/Carbon","slug":"unit","errorCode":null,"errorMessage":"$unit","messagePattern":"\\$unit","errorType":"exception","errorClass":"UnknownUnitException","httpStatus":null,"severity":"error","filePath":"src/Carbon/Traits/Difference.php","lineNumber":112,"sourceCode":"    }\n\n    /**\n     * @param Unit|string                                            $unit     microsecond, millisecond, second, minute,\n     *                                                                         hour, day, week, month, quarter, year,\n     *                                                                         century, millennium\n     * @param \\Carbon\\CarbonInterface|\\DateTimeInterface|string|null $date\n     * @param bool                                                   $absolute Get the absolute of the difference\n     * @param bool                                                   $utc      Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)\n     *\n     * @return float\n     */\n    public function diffInUnit(Unit|string $unit, $date = null, bool $absolute = false, bool $utc = false): float\n    {\n        $unit = static::pluralUnit($unit instanceof Unit ? $unit->value : rtrim($unit, 'z'));\n        $method = 'diffIn'.$unit;\n\n        if (!method_exists($this, $method)) {\n            throw new UnknownUnitException($unit);\n        }\n\n        return $this->$method($date, $absolute, $utc);\n    }\n\n    /**\n     * Get the difference in years\n     *\n     * @param \\Carbon\\CarbonInterface|\\DateTimeInterface|string|null $date\n     * @param bool                                                   $absolute Get the absolute of the difference\n     * @param bool                                                   $utc      Always convert dates to UTC before comparing (if not set, it will do it only if timezones are different)\n     *\n     * @return float\n     */\n    public function diffInYears($date = null, bool $absolute = false, bool $utc = false): float\n    {\n        $start = $this;\n        $end = $this->resolveCarbon($date);","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/briannesbitt/Carbon/blob/b13f05955dcfd7da71d60af745fd148cbdb73505/src/Carbon/Traits/Difference.php#L94-L130","documentation":"Error \"$unit\" thrown in briannesbitt/Carbon.","triggerScenarios":"Thrown at src/Carbon/Traits/Difference.php:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b13f05955dcfd7da71d60af745fd148cbdb73505","analyzedAt":"2026-08-17T04:40:56.953Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}