Parse and validate AT Protocol Lexicons with DTO generation for Laravel
at dev 713 B view raw
1<?php 2 3namespace SocialDept\AtpSchema\Exceptions; 4 5use Exception; 6 7class SchemaException extends Exception 8{ 9 /** 10 * Additional context data for the exception. 11 */ 12 protected array $context = []; 13 14 /** 15 * Set context data. 16 */ 17 public function setContext(array $context): self 18 { 19 $this->context = $context; 20 21 return $this; 22 } 23 24 /** 25 * Get context data. 26 */ 27 public function getContext(): array 28 { 29 return $this->context; 30 } 31 32 /** 33 * Create exception with context. 34 */ 35 public static function withContext(string $message, array $context = []): self 36 { 37 return (new static($message))->setContext($context); 38 } 39}