Conflict class represents an HTTP error response with status code 409. It is used to standardize "Conflict" error responses, typically when a request conflicts with the current state of a resource.ts
import { Conflict } from "@arkyn/server";
message (required): A descriptive message explaining the conflict cause.cause (optional): Additional information about the conflict cause, which can be any serializable data.toResponse() - Converts the instance into a Response object with JSON body and Content-Type: application/json header.toJson() - Alternative method using Response.json() for generating the JSON error response.typescript
import { Conflict } from "@arkyn/server";// Basic usage - throw the errorthrow new Conflict("Email already registered");// With cause informationthrow new Conflict("Resource version mismatch", {currentVersion: 5,requestedVersion: 3,});// Convert to Response objectconst error = new Conflict("Username already taken");return error.toResponse();// Using toJson alternativereturn error.toJson();
json
{"ok": false,"status": 409,"message": "Email already registered"}
cause parameter is serialized to JSON and stored for debugging purposes but is not included in the response body sent to clients.