Server Error
https://bessapay.net/errors/server-errorOverview
A Server Error occurs when something unexpected happens on the BessaPay server while processing your request. These errors are not caused by your request but by an issue on our side, and are returned with HTTP status code 500.
Details
- Error Code: SERVER_ERROR
- HTTP Status: 500
- Error Type: Server Error
Common scenarios
- • Unexpected exception in API code
- • Database connection issues
- • Dependent service unavailability
- • Resource limitations (memory, CPU)
- • Configuration issues
Example
Server Error Response
1{
2 "type": "https://bessapay.net/errors/server-error",
3 "title": "Internal Server Error",
4 "status": 500,
5 "detail": "An unexpected error occurred while processing your request",
6 "instance": "/api/v1/transactions/process",
7 "errorCode": "SERVER_ERROR",
8 "timestamp": "2023-06-15T17:30:45Z",
9 "traceId": "1a2b3c4d5e6f7g8h9i0j"
10}How to Handle
Retry the request
Many server errors are temporary. Implement a retry mechanism with exponential backoff to automatically retry failed requests after a short delay.
Check service status
Check the BessaPay status page at status.semuni.com to see if there's a known service disruption.
Contact support
If the issue persists, contact BessaPay support and provide the traceId from the error response. This helps our team identify and fix the specific issue you encountered.
Implement graceful degradation
Design your application to handle API outages gracefully. Consider implementing:
- Fallback behavior when the API is unavailable
- Queuing of requests for later retry
- Caching of previous responses to serve during outages
- Clear user communication about temporary issues
Code Example: Handling Server Errors
JavaScript Server Error Handling
1// Example of handling Server Errors with retry logic
2async function processTransaction(transactionData, maxRetries = 3) {
3 let attempt = 0;
4
5 while (attempt < maxRetries) {
6 try {
7 const response = await fetch('https://api.semuni.com/v1/transactions/process', {
8 method: 'POST',
9 headers: {
10 'Authorization': `Bearer ${apiKey}`,
11 'Content-Type': 'application/json'
12 },
13 body: JSON.stringify(transactionData)
14 });
15
16 if (response.status === 500) {
17 const errorData = await response.json();
18 console.error(`Server error encountered (trace: ${errorData.traceId}):`, errorData);
19
20 // Wait before retrying
21 const delay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
22 console.log(`Attempt ${attempt + 1}/${maxRetries} failed. Retrying in ${delay}ms...`);
23 await new Promise(resolve => setTimeout(resolve, delay));
24
25 attempt++;
26 continue;
27 }
28
29 if (!response.ok) {
30 // Handle other errors
31 const errorData = await response.json();
32 throw new Error(errorData.detail || 'An error occurred');
33 }
34
35 // Success!
36 return await response.json();
37 } catch (error) {
38 if (attempt >= maxRetries - 1) {
39 throw error;
40 }
41
42 // For network errors, also retry
43 const delay = Math.pow(2, attempt) * 1000;
44 console.log(`Network error on attempt ${attempt + 1}/${maxRetries}. Retrying in ${delay}ms...`);
45 await new Promise(resolve => setTimeout(resolve, delay));
46
47 attempt++;
48 }
49 }
50
51 throw new Error(`Failed after ${maxRetries} attempts`);
52}
53
54// Usage example with error handling
55async function safeProcessTransaction(data) {
56 try {
57 const result = await processTransaction(data);
58 return result;
59 } catch (error) {
60 console.error('Processing failed:', error);
61
62 // Show appropriate message to the user
63 showErrorMessage('We're experiencing technical difficulties. Our team has been notified.');
64
65 // Log the error to your monitoring system
66 logErrorToMonitoring(error);
67
68 return null;
69 }
70}