@@ -347,6 +347,10 @@ impl ErrorMetadata {
347
347
self . code == ErrorCode :: Forbidden
348
348
}
349
349
350
+ pub fn is_misdirected_request ( & self ) -> bool {
351
+ self . code == ErrorCode :: MisdirectedRequest
352
+ }
353
+
350
354
/// Return true if this error is deterministically caused by user. If so,
351
355
/// we can propagate it into JS out of a syscall, and cache it if it is the
352
356
/// full UDF result.
@@ -499,7 +503,7 @@ impl ErrorCode {
499
503
ErrorCode :: PaginationLimit => tonic:: Code :: InvalidArgument ,
500
504
ErrorCode :: OutOfRetention => tonic:: Code :: OutOfRange ,
501
505
ErrorCode :: OperationalInternalServerError => tonic:: Code :: Internal ,
502
- ErrorCode :: MisdirectedRequest => tonic:: Code :: InvalidArgument ,
506
+ ErrorCode :: MisdirectedRequest => tonic:: Code :: FailedPrecondition ,
503
507
}
504
508
}
505
509
@@ -531,6 +535,7 @@ pub trait ErrorMetadataAnyhowExt {
531
535
fn is_forbidden ( & self ) -> bool ;
532
536
fn should_report_to_sentry ( & self ) -> Option < ( sentry:: Level , Option < f64 > ) > ;
533
537
fn is_deterministic_user_error ( & self ) -> bool ;
538
+ fn is_misdirected_request ( & self ) -> bool ;
534
539
fn user_facing_message ( & self ) -> String ;
535
540
fn short_msg ( & self ) -> & str ;
536
541
fn msg ( & self ) -> & str ;
@@ -618,6 +623,13 @@ impl ErrorMetadataAnyhowExt for anyhow::Error {
618
623
false
619
624
}
620
625
626
+ fn is_misdirected_request ( & self ) -> bool {
627
+ if let Some ( e) = self . downcast_ref :: < ErrorMetadata > ( ) {
628
+ return e. is_misdirected_request ( ) ;
629
+ }
630
+ false
631
+ }
632
+
621
633
/// Returns the level at which the given error should report to sentry
622
634
/// INFO -> it's a client-at-fault error
623
635
/// WARNING -> it's a server-at-fault error that is expected
0 commit comments