Factory method which creates a CompilationFailedException from the supplied AJC IMessages.

@param errors A non-empty array of IMessage objects which
@return A CompilationFailedException containing a string representation of the supplied errors.
556108
public static CompilationFailedException create(final IMessage[] errors) {

        final StringBuilder sb = new StringBuilder();
        sb.append("AJC compiler errors:").append(LINE_SEPARATOR);
        for (final IMessage error : errors) {
            sb.append(error.toString()).append(LINE_SEPARATOR);
        }

        return new CompilationFailedException(sb.toString());
    }
423532
protected CompilationProblem[] collectCompilerProblems() {
        if (this.errors.isEmpty()) {
            return null;
        } else {
            final CompilationProblem[] list = new CompilationProblem[this.errors.size()];
            this.errors.toArray(list);
            return list;
        }
    }
786540
@Nonnull
    public static ApiError parseError(@Nullable String errorBody, int statusCode, @Nullable String message) {
        if (errorBody == null) {
            return new ApiError(null, statusCode, message);
        }

        Moshi moshi = new Moshi.Builder().build();
        JsonAdapter<CompatibilityApiError> oldApiErrorJsonAdapter = moshi.adapter(CompatibilityApiError.class).failOnUnknown();
        try {
             return new ApiError(oldApiErrorJsonAdapter.fromJson(errorBody), statusCode);
        } catch (IOException | JsonDataException exception) {
            // Not old type of error, move on
        }

        JsonAdapter<ApiError> apiErrorJsonAdapter = moshi.adapter(ApiError.class).failOnUnknown();
        try {
            return apiErrorJsonAdapter.fromJson(errorBody);
        } catch (IOException | JsonDataException exception) {
            return new ApiError(null, statusCode, "Unknown Error");
        }
    }
1052781
public JsJmsTextMessage createJmsTextMessage() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createJmsTextMessage");
    JsJmsTextMessage msg = null;
    try {
      msg = new JsJmsTextMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createJmsTextMessage");
    return msg;
  }
454548
public static String formatErrors(Iterable<SoyError> errors) {
    int numErrors = 0;
    int numWarnings = 0;
    for (SoyError error : errors) {
      if (error.isWarning()) {
        numWarnings++;
      } else {
        numErrors++;
      }
    }
    if (numErrors + numWarnings == 0) {
      throw new IllegalArgumentException("cannot format 0 errors");
    }
    StringBuilder sb =
        new StringBuilder(numErrors == 0 ? "warnings" : "errors")
            .append(" during Soy compilation\n");
    Joiner.on('\n').appendTo(sb, errors);
    if (numErrors > 0) {
      formatNumber(numErrors, "error", sb);
    }
    if (numWarnings > 0) {
      if (numErrors > 0) {
        sb.append(' ');
      }
      formatNumber(numWarnings, "warning", sb);
    }
    return sb.append('\n').toString();
  }
151697
private String createErrorMsg(JspLineId jspLineId, int errorLineNr) {
        StringBuffer compilerOutput = new StringBuffer();

        if (jspLineId.getSourceLineCount() <= 1) {
			Object[] objArray = new Object[] { new Integer(jspLineId.getStartSourceLineNum()), jspLineId.getFilePath()};
			if (jspLineId.getFilePath().equals(jspLineId.getParentFile())) {
				compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number", objArray));  // Defect 211450
			}
			else {
				compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number.included.file", objArray));  // Defect 211450
			}
        }
        else {
			// compute exact JSP line number 
			int actualLineNum=jspLineId.getStartSourceLineNum()+(errorLineNr-jspLineId.getStartGeneratedLineNum());
			if (actualLineNum>=jspLineId.getStartSourceLineNum() && actualLineNum <=(jspLineId.getStartSourceLineNum() + jspLineId.getSourceLineCount() - 1)) {
				Object[] objArray = new Object[] { new Integer(actualLineNum), jspLineId.getFilePath()};
				if (jspLineId.getFilePath().equals(jspLineId.getParentFile())) {
					compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number", objArray));  // Defect 211450
				}
				else {
					compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number.included.file", objArray));  // Defect 211450
				}
			}
			else {
				Object[] objArray = new Object[] {
					new Integer(jspLineId.getStartSourceLineNum()),
					new Integer((jspLineId.getStartSourceLineNum()) + jspLineId.getSourceLineCount() - 1),
					jspLineId.getFilePath()};
				if (jspLineId.getFilePath().equals(jspLineId.getParentFile())) {
					compilerOutput.append(separatorString+  // Defect 211450
						JspCoreException.getMsg(
							"jsp.error.multiple.line.number", objArray));
				}
				else {
					compilerOutput.append(separatorString+  // Defect 211450
						JspCoreException.getMsg(
							"jsp.error.multiple.line.number.included.file",objArray));
				}
			}
        }

		compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.corresponding.servlet",new Object[] { jspLineId.getParentFile()}));  // Defect 211450
		    //152470 starts
	        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINER)) {
	            logger.logp(Level.FINER, CLASS_NAME, "createErrorMsg", "The value of the JSP attribute jdkSourceLevel is ["+ jdkSourceLevel +"]");
	        }
	        //152470 ends
        return compilerOutput.toString();
    }
640521
public void addError(String error) {
    ActionMessages messages = (ActionMessages) next.get(Flash.MESSAGES);
    if (null == messages) {
      messages = new ActionMessages();
      put(Flash.MESSAGES, messages);
    }
    messages.getErrors().add(error);
  }
1373324
public String formatErrors() {

		if (errors.size() > 0) {

			StringBuilder results = new StringBuilder();

			for (Throwable t : errors) {
				results.append(t.getMessage());
				results.append("\n");
				if (t instanceof NullPointerException
						|| t instanceof CompilerError) {

					results.append(formatStackTrace(t));

				} else if (t instanceof SystemException) {

					results.append(formatStackTrace(t));

					Throwable cause = t.getCause();
					if (cause != null) {
						results.append("\nCause:\n");
						results.append(cause.getMessage());
						results.append("\n");
					}
					results.append(formatStackTrace(t));
				}
			}
			return results.toString();
		} else {
			return null;
		}
	}
1311325
private String createError(String errorMsg) {

        StringBuffer result = new StringBuffer();

        result.append("ERR");
        result.append(errorMsg);

        return result.toString();
    }
757359
@SuppressWarnings("unchecked")
    protected JsonObject paramError(Map<String, Object> errors) {
        JsonObject json = JsonObject.create();
        json.setStatus(GlobalResponseStatusMsg.SYSTEM_ERROR.getMessage().getCode());
        Map<String, Object> error = new HashMap<String, Object>();
        error.put(WebResponseConstant.MESSAGE_FIELD, errors);
        json.setStatusInfo(error);
        return json;
    }
867589
protected Throwable composeErrors(Throwable... errors) {

    if (errors == null) {
      return new NullPointerException("errors");
    } else if (errors.length == 1) {
      return errors[0];
    } else {
      return new ComposedException(errors);
    }
  }
1170555
private M invalidMessage(Exception cause) {
        state = State.BAD_MESSAGE;
        M message = buildInvalidMessage();
        message.setDecoderResult(DecoderResult.failure(cause));
        return message;
    }
1117445
private static ErrorItem.Builder toErrorItemBuilderWithoutCause(final String logMessage, final Throwable t) {
		ErrorItem.Builder builder = ErrorItem.newBuilder();
		builder.message(toErrorItemMessage(logMessage, t.getMessage()));
		builder.errorType(t.getClass().getCanonicalName());
		
		List<TraceFrame> stackFrames = new ArrayList<TraceFrame>();
		
		StackTraceElement[] stackTrace = t.getStackTrace();
		
		if ((stackTrace != null) && (0 < stackTrace.length)) {
			StackTraceElement firstFrame = stackTrace[0];
			builder.sourceMethod(firstFrame.getClassName() + "." + firstFrame.getMethodName());
			
			for (int i = 0; i < stackTrace.length; ++i) {
				TraceFrame stackFrame = StackTraceElements.toTraceFrame(stackTrace[i]);
				stackFrames.add(stackFrame);
			}
		}
		
		builder.stackTrace(stackFrames);
		
		return builder;
	}
944347
private ModelAndView buildError(String errorMsg, ErrorCode errorCode) {

        JsonObjectBase jsonObject = JsonObjectUtils.buildGlobalError(errorMsg, errorCode);
        return JsonObjectUtils.JsonObjectError2ModelView((JsonObjectError) jsonObject);
    }
898262
private static JSONObject genError(Integer code, String message) throws JSONException {
        // TODO: HTTP-Status (404, etc), for now return status line
        return new JSONObject("{error: {code: \"" + code.toString() + "\", message: \"" + message + "\"}}");
    }
423124
public static List<Result.Error> parseErrors(Throwable exception, int status) {
        List<Result.Error> errors = Lists.newArrayList();
        if (status == 500 || status == 400) {
            Throwable cause = exception;
            while (cause != null) {
                StackTraceElement[] stackTraceElements = cause.getStackTrace();
                if (stackTraceElements != null && stackTraceElements.length > 0) {
                    Result.Error error = new Result.Error(
                            Hashing.murmur3_32().hashUnencodedChars(exception.getClass().getName()).toString(),
                            cause.getMessage());

                    if (status == 500) {
                        StringBuilder descBuilder = new StringBuilder();
                        for (StackTraceElement element : stackTraceElements) {
                            descBuilder
                                    .append(element.toString())
                                    .append("\n");
                        }

                        error.setDescription(descBuilder.toString());
                    }
                    StackTraceElement stackTraceElement = stackTraceElements[0];
                    String source = stackTraceElement.toString();
                    error.setSource(source);

                    errors.add(error);
                }
                cause = cause.getCause();
            }
        }

        return errors;
    }
541535
private String createError(String errorMsg, Throwable t) {

        StringBuffer msg = new StringBuffer();
        msg.append(errorMsg);
        msg.append("\n");
        msg.append(t.getMessage());
        msg.append("\n");
        msg.append(CmsException.getStackTraceAsString(t));

        return createError(msg.toString());
    }