use super::SessionError;
pub fn jsonrpc_code(err: &SessionError) -> i64 {
match err {
SessionError::NotFound { .. } => -32001,
SessionError::Busy { .. } => -32002,
SessionError::PersistenceDisabled => -32003,
SessionError::CompactionDisabled => -32004,
SessionError::NotRunning { .. } => -32005,
SessionError::Store(_) => -32006,
SessionError::Agent(_) => -32000,
}
}
pub fn http_status(err: &SessionError) -> u16 {
match err {
SessionError::NotFound { .. } => 404,
SessionError::Busy { .. } => 409,
SessionError::PersistenceDisabled => 501,
SessionError::CompactionDisabled => 501,
SessionError::NotRunning { .. } => 409,
SessionError::Store(_) => 500,
SessionError::Agent(_) => 500,
}
}
pub fn cli_exit_code(err: &SessionError) -> i32 {
match err {
SessionError::PersistenceDisabled | SessionError::CompactionDisabled => {
0
}
_ => 1,
}
}