File tree Expand file tree Collapse file tree
rivetkit-rust/packages/rivetkit-core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use serde_json::Value as JsonValue;
44
55pub fn public_error_status_code ( group : & str , code : & str ) -> Option < u16 > {
66 match ( group, code) {
7+ ( "user" , _) => Some ( 400 ) ,
78 ( "auth" , "forbidden" ) => Some ( 403 ) ,
89 ( "actor" , "action_not_found" ) => Some ( 404 ) ,
910 ( "actor" , "action_timed_out" ) => Some ( 408 ) ,
Original file line number Diff line number Diff line change @@ -29,6 +29,31 @@ fn preserves_public_error_message_for_client_boundary() {
2929 assert_eq ! ( error. client_message( ) , "action `missing` was not found" ) ;
3030}
3131
32+ #[ test]
33+ fn preserves_user_error_metadata_for_client_boundary ( ) {
34+ let metadata = serde_json:: json!( {
35+ "error" : {
36+ "_tag" : "CounterOverflowError" ,
37+ "limit" : 20 ,
38+ } ,
39+ } ) ;
40+ let error = ActionDispatchError :: from_anyhow ( anyhow:: Error :: new ( RivetError {
41+ kind : RivetErrorKind :: Dynamic {
42+ group : "user" . to_owned ( ) ,
43+ code : "Increment" . to_owned ( ) ,
44+ default_message : "count 25 would exceed limit 20" . to_owned ( ) ,
45+ } ,
46+ meta : serde_json:: value:: to_raw_value ( & metadata) . ok ( ) ,
47+ message : None ,
48+ actor : None ,
49+ } ) ) ;
50+
51+ assert_eq ! ( error. group, "user" ) ;
52+ assert_eq ! ( error. code, "Increment" ) ;
53+ assert_eq ! ( error. client_message( ) , "count 25 would exceed limit 20" ) ;
54+ assert_eq ! ( error. client_metadata( ) , Some ( & metadata) ) ;
55+ }
56+
3257#[ test]
3358fn masks_private_structured_message_at_client_boundary ( ) {
3459 static TEST_ERROR : RivetErrorSchema = RivetErrorSchema {
You can’t perform that action at this time.
0 commit comments