Parse and validate AT Protocol Lexicons with DTO generation for Laravel
1<?php
2
3namespace SocialDept\AtpSchema\Exceptions;
4
5class SchemaParseException extends SchemaException
6{
7 /**
8 * Create exception for invalid JSON.
9 */
10 public static function invalidJson(string $nsid, string $error): self
11 {
12 return static::withContext(
13 "Failed to parse schema JSON for {$nsid}: {$error}",
14 ['nsid' => $nsid, 'error' => $error]
15 );
16 }
17
18 /**
19 * Create exception for malformed schema.
20 */
21 public static function malformed(string $nsid, string $reason): self
22 {
23 return static::withContext(
24 "Malformed schema for {$nsid}: {$reason}",
25 ['nsid' => $nsid, 'reason' => $reason]
26 );
27 }
28}