예제 #1
0
sgx_status_t check(sgx_status_t rc, char* error_msg) {
  if (rc != SGX_SUCCESS) {
    char* desc = get_error_description(rc);
    fprintf(stderr, "%s (%s)\n", error_msg, desc);
  }
  return rc;
}
int write_key_to_file(char ERROR_CODES_FILE [], char REF_ERROR_CODES_FILE [], char fits_key [], int fits_key_value, char fits_key_comment [], char ERROR_CODES_FILE_WRITE_ACCESS []) {

	FILE *ERROR_CODES_FILE_ptr;
	ERROR_CODES_FILE_ptr = fopen(ERROR_CODES_FILE, ERROR_CODES_FILE_WRITE_ACCESS);

	FILE *REF_ERROR_CODES_FILE_ptr;
	REF_ERROR_CODES_FILE_ptr = fopen(REF_ERROR_CODES_FILE, "r");

	char verbose_comment [200];
	memset(verbose_comment, '\0', sizeof(char)*200);

	char severity [50];
	memset(severity, '\0', sizeof(char)*50);

	if (ERROR_CODES_FILE_ptr && REF_ERROR_CODES_FILE_ptr) {

		if(!get_error_description(REF_ERROR_CODES_FILE_ptr, fits_key_value, fits_key, verbose_comment, severity)) {

			printf("\nRoutine outcome\n");
			printf("---------------\n");

			fprintf(ERROR_CODES_FILE_ptr, "%s\t%d\t%s\n", fits_key, fits_key_value, fits_key_comment);
			printf("\n%s:\t%s.\n", severity, verbose_comment);
			printf("\t\tWrote error code value %d associated with key %s to file %s with comment \"%s\".\n\n", fits_key_value, fits_key, ERROR_CODES_FILE, fits_key_comment);

			fclose(ERROR_CODES_FILE_ptr);
			return 0;

		} else {

			return 1;

		}

	} else {	// failed to find output error codes file or reference error codes file

		if (!ERROR_CODES_FILE_ptr && REF_ERROR_CODES_FILE_ptr) {

			printf("\nWARNING:\tUnable to write error code to file. File %s doesn't exist.\n\n", ERROR_CODES_FILE);
			fclose(REF_ERROR_CODES_FILE_ptr);
			return 1;

		} else if (ERROR_CODES_FILE_ptr && !REF_ERROR_CODES_FILE_ptr) {

			printf("\nWARNING:\tUnable to write error code to file. File %s doesn't exist.\n\n", REF_ERROR_CODES_FILE);
			fclose(ERROR_CODES_FILE_ptr);
			return 1;

		} else {

			printf("\nWARNING:\tUnable to write error code to file. Files %s and %s don't exist.\n\n", REF_ERROR_CODES_FILE, ERROR_CODES_FILE);
			return 1;

		}


	}

}
예제 #3
0
파일: yusb.c 프로젝트: emmt/yusb
static void failure(const char* reason, int code)
{
  static char msg[256];
  if (reason == NULL || reason[0] == 0) {
    y_error(get_error_description(code));
  } else {
    sprintf(msg, "%s [%s]",  reason, get_error_name(code));
    y_error(msg);
  }
}
예제 #4
0
파일: yusb.c 프로젝트: emmt/yusb
void Y_usb_error_description(int argc)
{
  if (argc != 1) y_error("expected exactly one argument");
  push_string(get_error_description(ygets_i(0)));
}
예제 #5
0
/* Event handler for tool 'error-support' */
ATerm error_support_handler(int conn, ATerm term)
{
  ATerm in, out;
  /* We need some temporary variables during matching */
  char *s0, *s1;
  ATerm t0;

  if(ATmatch(term, "rec-eval(make-error(<str>,<term>))", &s0, &t0)) {
    return make_error(conn, s0, t0);
  }
  if(ATmatch(term, "rec-eval(get-area-end-line(<term>))", &t0)) {
    return get_area_end_line(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-location-filename(<term>))", &t0)) {
    return get_location_filename(conn, t0);
  }
  if(ATmatch(term, "rec-eval(has-location-area(<term>))", &t0)) {
    return has_location_area(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-summary-id(<term>))", &t0)) {
    return get_summary_id(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-error-description(<term>))", &t0)) {
    return get_error_description(conn, t0);
  }
  if(ATmatch(term, "rec-do(display-summary(<term>))", &t0)) {
    display_summary(conn, t0);
    return NULL;
  }
  if(ATmatch(term, "rec-eval(lower-summary(<term>))", &t0)) {
    return lower_summary(conn, t0);
  }
  if(ATmatch(term, "rec-eval(make-localized-subject(<str>,<term>))", &s0, &t0)) {
    return make_localized_subject(conn, s0, t0);
  }
  if(ATmatch(term, "rec-eval(get-summary-producer(<term>))", &t0)) {
    return get_summary_producer(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-error-subjects(<term>))", &t0)) {
    return get_error_subjects(conn, t0);
  }
  if(ATmatch(term, "rec-eval(make-subject(<str>))", &s0)) {
    return make_subject(conn, s0);
  }
  if(ATmatch(term, "rec-eval(get-subject-location(<term>))", &t0)) {
    return get_subject_location(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-area-offset(<term>))", &t0)) {
    return get_area_offset(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-area-begin-line(<term>))", &t0)) {
    return get_area_begin_line(conn, t0);
  }
  if(ATmatch(term, "rec-eval(add-filename-in-error(<str>,<term>))", &s0, &t0)) {
    return add_filename_in_error(conn, s0, t0);
  }
  if(ATmatch(term, "rec-eval(get-location-area(<term>))", &t0)) {
    return get_location_area(conn, t0);
  }
  if(ATmatch(term, "rec-eval(set-summary-id(<term>,<str>))", &t0, &s0)) {
    return set_summary_id(conn, t0, s0);
  }
  if(ATmatch(term, "rec-eval(has-subject-location(<term>))", &t0)) {
    return has_subject_location(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-area-end-column(<term>))", &t0)) {
    return get_area_end_column(conn, t0);
  }
  if(ATmatch(term, "rec-eval(make-summary(<str>,<str>,<term>))", &s0, &s1, &t0)) {
    return make_summary(conn, s0, s1, t0);
  }
  if(ATmatch(term, "rec-eval(get-summary-errors(<term>))", &t0)) {
    return get_summary_errors(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-subject-description(<term>))", &t0)) {
    return get_subject_description(conn, t0);
  }
  if(ATmatch(term, "rec-eval(get-area-length(<term>))", &t0)) {
    return get_area_length(conn, t0);
  }
  if(ATmatch(term, "rec-terminate(<term>)", &t0)) {
    rec_terminate(conn, t0);
    return NULL;
  }
  if(ATmatch(term, "rec-eval(get-area-begin-column(<term>))", &t0)) {
    return get_area_begin_column(conn, t0);
  }
  if(ATmatch(term, "rec-do(signature(<term>,<term>))", &in, &out)) {
    ATerm result = error_support_checker(conn, in);
    if(!ATmatch(result, "[]"))
      ATfprintf(stderr, "warning: not in input signature:\n\t%\n\tl\n", result);
    return NULL;
  }

  ATerror("tool error-support cannot handle term %t", term);
  return NULL; /* Silence the compiler */
}
예제 #6
0
파일: error.hpp 프로젝트: jaagr/xpp
 error(const std::shared_ptr<xcb_generic_error_t> & error)
   : runtime_error(get_error_description(error.get()))
   , m_error(error)
 {}