# Issue #212: Inconsistent Error Handling Across Controllers

## Problem

Different controllers handle errors differently:

**Logging inconsistency:**
```php
// Some controllers log errors:
$this->logger->error('Failed to create member', ['exception' => $e, ...]);

// Some controllers don't log at all
```

**Exception handling inconsistency:**
```php
// Some controllers catch multiple exception types:
} catch (DoesNotExistException $e) {
    return new JSONResponse(['error' => 'Not found'], 404);
} catch (\Exception $e) {
    return new JSONResponse(['error' => 'Server error'], 500);
}

// Some controllers use generic catches:
} catch (Exception $e) { ... }
```

**Error message language:**
```php
return new JSONResponse(['error' => 'Mitglied nicht gefunden'], 404);  // German
return new JSONResponse(['error' => 'Member not found'], 404);          // English
```

## Impact

- Inconsistent user experience
- Difficult to debug production issues
- Potential information leakage (stack traces in logs)
- Mixed language in API responses

## Solution

1. Create a base controller with standardized error handling:
   ```php
   abstract class BaseApiController extends ApiController {
       protected function handleNotFound(DoesNotExistException $e): JSONResponse {
           $this->logger->warning('Resource not found', ['exception' => $e]);
           return $this->error('Resource not found', 404);
       }
       
       protected function handleError(\Exception $e, string $action): JSONResponse {
           $this->logger->error("$action failed", ['exception' => $e]);
           return $this->error('An error occurred', 500);
       }
   }
   ```

2. Define consistent error messages in one place (enum or constants)

3. Ensure all controllers extend the base class

## Tasks

- [ ] Create `BaseApiController` with standardized error methods
- [ ] Define `ErrorMessages` enum with all error strings
- [ ] Update all controllers to extend `BaseApiController`
- [ ] Ensure consistent logging (all errors logged, exceptions include context)
- [ ] Standardize on German or bilingual error messages
- [ ] Add tests for error handling behavior

## Labels

- bug
- backend
- priority:medium