Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions API_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,14 @@ Constructs a new `libak_ErrorResponse` with the specified status code, summary,
- `summary` (String): A summary message describing the error.
- `details` (String): Additional details about the error.

#### `libak_ErrorResponse(Integer statusCode, String summary)`

Constructs a new `libak_ErrorResponse` with the specified status code, summary.

- Parameters:
- `statusCode` (Integer): The HTTP status code for the error response.
- `summary` (String): A summary message describing the error.

#### `libak_ErrorResponse(Integer status, String summary, Exception exc)`

Constructs a new `libak_ErrorResponse` with the specified status code and summary, based on an exception.
Expand Down
18 changes: 9 additions & 9 deletions Developer_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public class CustomersProcessorV1 extends libak_RestProcessor {
];

if (accounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Accounts are not found', '');
return new libak_ErrorResponse(404, 'Accounts are not found');
} else {
return new libak_JsonResponse(accounts);
}
Expand All @@ -213,7 +213,7 @@ public class CustomerProcessorV1 extends libak_RestProcessor {
];

if (accounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Accounts are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
} else {
return new libak_JsonResponse(accounts.get(0));
}
Expand All @@ -224,7 +224,7 @@ public class CustomerProcessorV1 extends libak_RestProcessor {
List<Account> existingAccounts = [SELECT Id FROM Account WHERE Id = :accountId];

if (existingAccounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Account are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
}

Account updatedAccount = (Account)JSON.deserialize(this.request.requestBody.toString(), Account.class);
Expand All @@ -238,7 +238,7 @@ public class CustomerProcessorV1 extends libak_RestProcessor {
List<Account> existingAccounts = [SELECT Id FROM Account WHERE Id = :accountId];

if (existingAccounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Account are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
}

delete existingAccounts.get(0);
Expand Down Expand Up @@ -303,7 +303,7 @@ global with sharing class CustomerWebServiceDemo {
];

if (accounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Accounts are not found', '');
return new libak_ErrorResponse(404, 'Accounts are not found');
} else {
return new libak_JsonResponse(accounts);
}
Expand All @@ -326,7 +326,7 @@ global with sharing class CustomerWebServiceDemo {
];

if (accounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Accounts are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
} else {
return new libak_JsonResponse(accounts.get(0));
}
Expand All @@ -337,7 +337,7 @@ global with sharing class CustomerWebServiceDemo {
List<Account> existingAccounts = [SELECT Id FROM Account WHERE Id = :accountId];

if (existingAccounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Account are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
}

Account updatedAccount = (Account)JSON.deserialize(this.request.requestBody.toString(), Account.class);
Expand All @@ -351,11 +351,11 @@ global with sharing class CustomerWebServiceDemo {
List<Account> existingAccounts = [SELECT Id FROM Account WHERE Id = :accountId];

if (existingAccounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Account are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
}

delete existingAccounts.get(0);
return new libak_SuccessResponse('Account deleted successfully');
return new libak_SuccessResponse('Account is deleted successfully');
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions demo-app/main/default/classes/CustomerWebServiceDemo.cls
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ global with sharing class CustomerWebServiceDemo {
];

if (accounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Accounts are not found', '');
return new libak_ErrorResponse(404, 'Accounts are not found');
} else {
return new libak_JsonResponse(accounts);
}
Expand All @@ -59,7 +59,7 @@ global with sharing class CustomerWebServiceDemo {
];

if (accounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Accounts are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
} else {
return new libak_JsonResponse(accounts.get(0));
}
Expand All @@ -70,7 +70,7 @@ global with sharing class CustomerWebServiceDemo {
List<Account> existingAccounts = [SELECT Id FROM Account WHERE Id = :accountId];

if (existingAccounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Account are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
}

Account updatedAccount = (Account)JSON.deserialize(this.request.requestBody.toString(), Account.class);
Expand All @@ -84,7 +84,7 @@ global with sharing class CustomerWebServiceDemo {
List<Account> existingAccounts = [SELECT Id FROM Account WHERE Id = :accountId];

if (existingAccounts.isEmpty()) {
return new libak_ErrorResponse(404, 'Account are not found', '');
return new libak_ErrorResponse(404, 'Account is not found');
}

delete existingAccounts.get(0);
Expand Down
18 changes: 14 additions & 4 deletions force-app/main/default/classes/libak_ErrorResponse.cls
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public class libak_ErrorResponse implements libak_IRestResponse {
this.summary = summary;
this.details = details;
}

/**
* Constructs a new `libak_ErrorResponse` with the specified status code, summary, and details.
*
* @param statusCode The HTTP status code for the error response.
* @param summary A summary message describing the error.
*/
public libak_ErrorResponse(Integer statusCode, String summary) {
this(statusCode, summary, summary);
}

/**
* Constructs a new `libak_ErrorResponse` with the specified status code and summary,
Expand All @@ -30,8 +40,8 @@ public class libak_ErrorResponse implements libak_IRestResponse {
* @param summary A summary message describing the error.
* @param exc The exception from which to derive error details.
*/
public libak_ErrorResponse(Integer status, String summary, Exception exc) {
this(status, summary, exc?.getMessage());
public libak_ErrorResponse(Integer statusCode, String summary, Exception exc) {
this(statusCode, summary, exc?.getMessage());
}

/**
Expand All @@ -41,8 +51,8 @@ public class libak_ErrorResponse implements libak_IRestResponse {
* @param status The HTTP status code for the error response.
* @param exc The exception from which to derive error details.
*/
public libak_ErrorResponse(Integer status, Exception exc) {
this(status, exc?.getMessage(), exc);
public libak_ErrorResponse(Integer statusCode, Exception exc) {
this(statusCode, exc?.getMessage(), exc?.getMessage());
}

/**
Expand Down
Loading