Functions

gs_error.c File Reference

#include <stdio.h>
#include "idl_export.h"
#include "grpc.h"
Include dependency graph for gs_error.c:

Go to the source code of this file.

Functions

IDL_VPTR gs_error_string (int argc, IDL_VPTR *argv_idl)
IDL_VPTR gs_get_last_error (int argc, IDL_VPTR *argv_idl)

Function Documentation

IDL_VPTR gs_error_string ( int  argc,
IDL_VPTR *  argv_idl 
)

Implementation of gs_error_string() and gs_get_last_error(). These are routines for obtaining and printing error messages from GridRPC.

This is part of the IDL Client for GridSolve. Gets the GridRPC error message (string) corresponding to the specified error number.

Parameters:
argc -- the number of arguments
argv_idl -- the array of IDL arguments passed in. this should contain one argument: the error number to look up.
Returns:
an IDL string variable containing the error message.

Definition at line 28 of file gs_error.c.

{
  grpc_error_t retval;
  int status;

  IDL_ENSURE_SCALAR(argv_idl[0]);

  status = IDL_LongScalar(argv_idl[0]);

  /* Initialize GridRPC system */
  retval = grpc_initialize(NULL);
  if((retval != GRPC_NO_ERROR) && (retval != GRPC_ALREADY_INITIALIZED)) {
    IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, "Error: cannot initialize!");
    return IDL_StrToSTRING("Init failed.");
  }
  
  return IDL_StrToSTRING(grpc_error_string((grpc_error_t)status));
}

Here is the call graph for this function:

IDL_VPTR gs_get_last_error ( int  argc,
IDL_VPTR *  argv_idl 
)

Gets the last GridRPC error code that was generated. This includes successful calls, too.

Parameters:
argc -- the number of arguments
argv_idl -- the array of IDL arguments passed in. this should be empty.
Returns:
an IDL variable containing the GridRPC exit status of the last call.

Definition at line 60 of file gs_error.c.

{
  grpc_sessionid_t id;
  grpc_error_t retval;

  /* Initialize GridRPC system */
  retval = grpc_initialize(NULL);
  if((retval != GRPC_NO_ERROR) && (retval != GRPC_ALREADY_INITIALIZED)) {
    IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, "Error: cannot initialize!");
    return IDL_GettmpLong(retval);
  }

  if(grpc_get_failed_sessionid(&id) != GRPC_NO_ERROR) {
    IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, 
      "Error: could not get last failed session ID.");
    return IDL_GettmpLong(0);
  }

  return IDL_GettmpLong(grpc_get_error(id));
}

Here is the call graph for this function:

Here is the caller graph for this function: