• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MrReasonable / jira-analyzer / 14283901362

05 Apr 2025 04:48PM UTC coverage: 76.058% (-7.8%) from 83.853%
14283901362

push

github

MrReasonable
refactor: implement clean architecture and improve UI components

This commit introduces a major architectural refactoring across the entire application:

Backend:

Implement clean architecture with repositories, services, and dependency injection
Add authentication and rate limiting middleware
Create dedicated routers for different API endpoints
Improve configuration management and Jira client handling
Add caching service for better performance
Frontend:

Restructure configuration form with multi-step wizard
Add notification system for better user feedback
Implement form validation and error handling utilities
Create dedicated workflow editor components
Improve test coverage with behavior and unit tests
E2E Tests:

Add test environment documentation and configuration
Implement chart verification utilities
Reorganize test structure for better maintainability
This refactoring improves code organization, testability, and maintainability while enhancing the user experience with better form handling and feedback mechanisms.

711 of 778 branches covered (91.39%)

Branch coverage included in aggregate %.

1807 of 2774 new or added lines in 59 files covered. (65.14%)

4 existing lines in 3 files now uncovered.

3028 of 4138 relevant lines covered (73.18%)

5.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/frontend/src/utils/apiErrorHandler.ts
NEW
1
import { logger } from '@utils/logger'
×
2

3
/**
4
 * Function to handle API errors consistently
5
 */
NEW
6
export const handleApiError = (err: unknown, defaultMessage: string): string => {
×
7
  // Default error message
NEW
8
  let errorMessage = defaultMessage
×
9

10
  // Handle HTTP status code errors with user-friendly messages
NEW
11
  if (
×
NEW
12
    err &&
×
NEW
13
    typeof err === 'object' &&
×
NEW
14
    'response' in err &&
×
NEW
15
    err.response &&
×
NEW
16
    typeof err.response === 'object' &&
×
NEW
17
    'status' in err.response
×
NEW
18
  ) {
×
NEW
19
    const status = Number(err.response.status)
×
20

NEW
21
    if (status === 401) {
×
NEW
22
      errorMessage = 'Invalid credentials. Please check your email and API token.'
×
NEW
23
    } else if (status === 403) {
×
NEW
24
      errorMessage = 'You do not have permission to access this Jira instance.'
×
NEW
25
    } else if (status === 404) {
×
NEW
26
      errorMessage = 'Jira server not found. Please check the server URL.'
×
NEW
27
    } else if (status === 409) {
×
NEW
28
      errorMessage =
×
NEW
29
        'A configuration with this name already exists. Please choose a different name.'
×
NEW
30
    } else if (status >= 500) {
×
NEW
31
      errorMessage = 'Jira server error. Please try again later.'
×
NEW
32
    }
×
NEW
33
  }
×
34

35
  // Check for network errors
NEW
36
  if (
×
NEW
37
    err &&
×
NEW
38
    typeof err === 'object' &&
×
NEW
39
    (('code' in err && err.code === 'ERR_NETWORK') ||
×
NEW
40
      ('code' in err && err.code === 'ECONNREFUSED') ||
×
NEW
41
      ('message' in err &&
×
NEW
42
        typeof err.message === 'string' &&
×
NEW
43
        err.message.includes('Network Error')))
×
NEW
44
  ) {
×
NEW
45
    errorMessage =
×
NEW
46
      'Unable to connect to the Jira server. Please check your internet connection and server URL.'
×
NEW
47
  }
×
48

49
  // Check for bad gateway errors
NEW
50
  if (
×
NEW
51
    err &&
×
NEW
52
    typeof err === 'object' &&
×
NEW
53
    'code' in err &&
×
NEW
54
    err.code === 'ERR_BAD_RESPONSE' &&
×
NEW
55
    'status' in err &&
×
NEW
56
    err.status === 502
×
NEW
57
  ) {
×
NEW
58
    errorMessage =
×
NEW
59
      'Unable to connect to the Jira API. Please check your server URL and credentials, or try again later.'
×
NEW
60
  }
×
61

62
  // If the error contains "JiraError HTTP 401", it's likely an authentication issue
NEW
63
  if (
×
NEW
64
    err &&
×
NEW
65
    typeof err === 'object' &&
×
NEW
66
    'message' in err &&
×
NEW
67
    typeof err.message === 'string' &&
×
NEW
68
    err.message.includes('JiraError HTTP 401')
×
NEW
69
  ) {
×
NEW
70
    errorMessage = 'Invalid credentials. Please check your email and API token.'
×
NEW
71
  }
×
72

NEW
73
  return errorMessage
×
NEW
74
}
×
75

76
export type ApiRequest<T> = () => Promise<T>
77

78
/**
79
 * Function that handles API requests with error handling and state updates
80
 */
NEW
81
export const handleApiRequest = async <T>(
×
NEW
82
  request: ApiRequest<T>,
×
NEW
83
  defaultErrorMessage: string,
×
NEW
84
  setError: (error: string | null) => void,
×
NEW
85
  onSuccess?: (result: T) => void,
×
NEW
86
  onError?: (errorMessage: string) => void
×
NEW
87
): Promise<T | null> => {
×
NEW
88
  try {
×
NEW
89
    const result = await request()
×
NEW
90
    if (onSuccess) {
×
NEW
91
      onSuccess(result)
×
NEW
92
    }
×
NEW
93
    return result
×
NEW
94
  } catch (err) {
×
NEW
95
    const errorMessage = handleApiError(err, defaultErrorMessage)
×
NEW
96
    setError(errorMessage)
×
NEW
97
    logger.error(defaultErrorMessage, err)
×
NEW
98
    if (onError) {
×
NEW
99
      onError(errorMessage)
×
NEW
100
    }
×
NEW
101
    return null
×
NEW
102
  }
×
NEW
103
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc