fferpcore.ErpErrorBodyglobal inherited sharing virtual class ErpErrorBody Methods
ErpErrorBodyglobal ErpErrorBody() Default constuctor for ErpErrorBody. Initially, the fferpcore.ErpErrorBody constructed by this method does not have any errors set on it. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /* * Look through the messages in the request and deal with any errors. */ private void checkForErrors(fferpcore.HandleMessagesRequest request) { for(fferpcore.DeliveredMessage message : request.getMessages()) { if(!message.hasResponse()) { message.respondError(new fferpcore.ErpErrorBody()); } } } ErpErrorBodyglobal ErpErrorBody(String message) Constructs an fferpcore.ErpErrorBody with the specified error message set on it. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /* * Look through the messages in the request and deal with any errors. */ private void checkForErrors(fferpcore.HandleMessagesRequest request) { for(fferpcore.DeliveredMessage message : request.getMessages()) { if(!message.hasResponse()) { message.respondError(new fferpcore.ErpErrorBody("An error has occured")); } } } ErpErrorBodyglobal ErpErrorBody(List<String> messages) Constructs an fferpcore.ErpErrorBody with the specified list of error messages set on it. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /* * Look through the messages in the request and deal with any errors. */ private void checkForErrors(fferpcore.HandleMessagesRequest request) { for(fferpcore.DeliveredMessage message : request.getMessages()) { //handleMessage has been implemented to return a list of error messages. List<String> errors = handleMessage(message); if(errors.size() > 0) { message.respondError(new fferpcore.ErpErrorBody(errors)); } } } addErrorMessageglobal void addErrorMessage(String message) Used to add an error message to the body of a failed message delivery. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public fferpcore.ErpErrorBody buildErrorBody(List<Database.Error> errors) { fferpcore.ErpErrorBody body = new ErpErrorBody(); for(Database.Error error : errors) { body.addErrorMessage(error.getMessage()); } return body; } getErpErrorBodyVersionglobal Integer getErpErrorBodyVersion() Returns the version number of ErpErrorBody. Return ValueThis service returns an Integer object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. Integer expectedVersion = 5; fferpcore.ErpErrorBody errorBody = getErrorBody(); // get an ErpErrorBody from somewhere System.assertEquals(expectedVersion, errorBody.getErpErrorBodyVersion()); getErrorMessagesglobal List<String> getErrorMessages() Returns the list of error messages assocaiated with this ErpErrorBody. Return ValueThis service returns a list of Errors as string objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.ErpErrorBody errorBody = new fferpcore.ErpErrorBody('Test message'); System.assertEquals(1, errorBody.getErrorMessages().size()); System.assertEquals('Test message', errorBody.getErrorMessages().get(0), 'The error provided should be the first error in the list.'); serializeglobal virtual String serialize() Returns a serialized version of the ErpErrorBody. The default implementation returns the object serialized into JSON format. If the the method is overridden on a subclass, the behavior may be different. Return ValueThis service returns a JSON representation of this error body. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.ErpErrorBody errorBody = getErrorBody(); // get an ErpErrorBody from somewhere String serializedErrorBody = errorBody.serialized(); //The serialized error body may be persisted at this point. deserializeglobal static fferpcore.ErpErrorBody deserialize(String jsonString) A static method that constructs an fferpcore.ErpErrorBody from a JSON string parameter. It reverses the effect of the serialize method. Return ValueThis method returns an ErpErrorBody.ErpErrorBody object. If the provided parameter is not a valid JSON string or does not contain either a ErrorMessages or ErpErrorBodyVersion field then null is returned. Extra fields are ignored. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.ErpErrorBody originalErrorBody = new fferpcore.ErpErrorBody('Error'); String jsonString = oroginalErrorBody.serialize(); fferpcore.ErpErrorBody newErrorBody = fferpcore.ErpErrorBody.deserialize(jsonString); System.assertEquals(oroginalErrorBody, newErrorBody, 'Recreated object should equal original object'); getDescriptionglobal static fferpcore.MessageDescription.Node getDescription() This static method returns an fferpcore.MessageDescription.Node describing the structure of an ErpErrorBody. Return ValueThis service returns an MessageDescription.Node object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Generates a description node describing a message. */ global static fferpcore.MessageDescription.Node getDescriptionNode(Schema.SObjectType context) { Schema.SObjectField idField = context.getDescribe().fields.getMap().get('Id'); fferpcore.MessageDescription.MapNode root = new fferpcore.MessageDescription.MapNode() .withChild('ObjectId', new fferpcore.MessageDescription.ScalarNode(new fferpcore.Context.SObjectSource(idField))) .withChild('ErrorBody', fferpcore.ErpErrorBody.getDescription()); return root; } equalsglobal Boolean equals(Object obj) Indicates when one fferpcore.ErpErrorBody is equal to another. Two ErpErrorBodys are considered equals if they have the same version and list of error messages. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.ErpErrorBody errorBody1 = new fferpcore.ErpErrorBody('Error'); fferpcore.ErpErrorBody errorBody2 = new fferpcore.ErpErrorBody('More Errors'); fferpcore.ErpErrorBody errorBody3 = new fferpcore.ErpErrorBody(List<String>{'Error'}); System.assert(!errorBody1.equals(errorBody2), 'These are not equal as the error messages are different'); System.assert(errorBody1.equals(errorBody3), 'These are equal as they have the same version and error messages'); hashcodeglobal Integer hashcode() Returns an Integer computed from the Version and Error Messages of this object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.ErpErrorBody errorBody1 = new fferpcore.ErpErrorBody('Error'); fferpcore.ErpErrorBody errorBody2 = new fferpcore.ErpErrorBody(List<String>{'Error'}); System.assertEquals(errorBody1.equals(errorBody2), 'These are equal as they have the same version and error messages'); System.assertEquals(errorBody1.hashcode(), errorBody2.hashcode()); |