Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :articles, only: [:index, :show, :create, :update, :destroy]
resources :sessions, only: [:create]
end
use serde::{Deserialize, Deserializer};
#[derive(Debug, Deserialize)]
pub struct ListFilter {
#[serde(default)]
pub status: Status,
// Basic try-catch
try {
const result = riskyOperation();
console.log('Success:', result);
} catch (error) {
console.error('Error occurred:', error.message);
import React, { Component, ReactNode } from 'react'
interface Props {
children: ReactNode
fallback?: ReactNode
onError?: (error: Error, errorInfo: React.ErrorInfo) => void
let installed = false;
function notify(message, level = "error") {
document.dispatchEvent(
new CustomEvent("flash:show", { detail: { message, level } })
);
use std::error::Error;
use std::fmt;
use std::io;
use std::num::ParseIntError;
#[derive(Debug)]
class ApiError extends Error {
constructor(statusCode, message, code) {
super(message);
this.name = 'ApiError';
this.statusCode = statusCode;
this.code = code || null;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
pub struct SignupRequest {
pub email: String,
pub password: String,
class ApplicationError < StandardError
attr_reader :context
class << self
def context_keys(*keys)
@context_keys = keys unless keys.empty?