@@ -58,6 +58,7 @@ export interface Rpc<
5858 readonly payloadSchema : Payload
5959 readonly successSchema : Success
6060 readonly errorSchema : Error
61+ readonly defectSchema : Schema . Schema < unknown , any >
6162 readonly annotations : Context_ . Context < never >
6263 readonly middlewares : ReadonlySet < Middleware >
6364
@@ -171,6 +172,7 @@ export interface AnyWithProps {
171172 readonly payloadSchema : AnySchema
172173 readonly successSchema : Schema . Schema . Any
173174 readonly errorSchema : Schema . Schema . All
175+ readonly defectSchema : Schema . Schema < unknown , any >
174176 readonly annotations : Context_ . Context < never >
175177 readonly middlewares : ReadonlySet < RpcMiddleware . TagClassAnyWithProps >
176178}
@@ -541,6 +543,7 @@ const Proto = {
541543 payloadSchema : this . payloadSchema ,
542544 successSchema,
543545 errorSchema : this . errorSchema ,
546+ defectSchema : this . defectSchema ,
544547 annotations : this . annotations ,
545548 middlewares : this . middlewares
546549 } )
@@ -551,6 +554,7 @@ const Proto = {
551554 payloadSchema : this . payloadSchema ,
552555 successSchema : this . successSchema ,
553556 errorSchema,
557+ defectSchema : this . defectSchema ,
554558 annotations : this . annotations ,
555559 middlewares : this . middlewares
556560 } )
@@ -561,6 +565,7 @@ const Proto = {
561565 payloadSchema : Schema . isSchema ( payloadSchema ) ? payloadSchema as any : Schema . Struct ( payloadSchema as any ) ,
562566 successSchema : this . successSchema ,
563567 errorSchema : this . errorSchema ,
568+ defectSchema : this . defectSchema ,
564569 annotations : this . annotations ,
565570 middlewares : this . middlewares
566571 } )
@@ -571,6 +576,7 @@ const Proto = {
571576 payloadSchema : this . payloadSchema ,
572577 successSchema : this . successSchema ,
573578 errorSchema : this . errorSchema ,
579+ defectSchema : this . defectSchema ,
574580 annotations : this . annotations ,
575581 middlewares : new Set ( [ ...this . middlewares , middleware ] )
576582 } )
@@ -581,6 +587,7 @@ const Proto = {
581587 payloadSchema : this . payloadSchema ,
582588 successSchema : this . successSchema ,
583589 errorSchema : this . errorSchema ,
590+ defectSchema : this . defectSchema ,
584591 annotations : this . annotations ,
585592 middlewares : this . middlewares
586593 } )
@@ -591,6 +598,7 @@ const Proto = {
591598 payloadSchema : this . payloadSchema ,
592599 successSchema : this . successSchema ,
593600 errorSchema : this . errorSchema ,
601+ defectSchema : this . defectSchema ,
594602 middlewares : this . middlewares ,
595603 annotations : Context_ . add ( this . annotations , tag , value )
596604 } )
@@ -601,6 +609,7 @@ const Proto = {
601609 payloadSchema : this . payloadSchema ,
602610 successSchema : this . successSchema ,
603611 errorSchema : this . errorSchema ,
612+ defectSchema : this . defectSchema ,
604613 middlewares : this . middlewares ,
605614 annotations : Context_ . merge ( this . annotations , context )
606615 } )
@@ -618,6 +627,7 @@ const makeProto = <
618627 readonly payloadSchema : Payload
619628 readonly successSchema : Success
620629 readonly errorSchema : Error
630+ readonly defectSchema : Schema . Schema < unknown , any >
621631 readonly annotations : Context_ . Context < never >
622632 readonly middlewares : ReadonlySet < Middleware >
623633} ) : Rpc < Tag , Payload , Success , Error , Middleware > => {
@@ -643,6 +653,7 @@ export const make = <
643653 readonly success ?: Success
644654 readonly error ?: Error
645655 readonly stream ?: Stream
656+ readonly defect ?: Schema . Schema < unknown , any >
646657 readonly primaryKey ?: [ Payload ] extends [ Schema . Struct . Fields ] ?
647658 ( ( payload : Schema . Simplify < Schema . Struct . Type < NoInfer < Payload > > > ) => string ) :
648659 never
@@ -678,6 +689,7 @@ export const make = <
678689 } ) :
679690 successSchema ,
680691 errorSchema : options ?. stream ? Schema . Never : errorSchema ,
692+ defectSchema : options ?. defect ?? Schema . Defect ,
681693 annotations : Context_ . empty ( ) ,
682694 middlewares : new Set < never > ( )
683695 } ) as any
@@ -719,6 +731,7 @@ export const fromTaggedRequest = <S extends AnyTaggedRequestSchema>(
719731 payloadSchema : schema as any ,
720732 successSchema : schema . success as any ,
721733 errorSchema : schema . failure ,
734+ defectSchema : Schema . Defect ,
722735 annotations : Context_ . empty ( ) ,
723736 middlewares : new Set ( )
724737 } )
@@ -747,7 +760,7 @@ export const exitSchema = <R extends Any>(
747760 const schema = Schema . Exit ( {
748761 success : Option . isSome ( streamSchemas ) ? Schema . Void : rpc . successSchema ,
749762 failure : Schema . Union ( ...failures ) ,
750- defect : Schema . Defect
763+ defect : rpc . defectSchema
751764 } )
752765 exitSchemaCache . set ( self , schema )
753766 return schema as any
0 commit comments