github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/runtime/ppapi/errors_nacl.go (about)

     1  // Copyright 2014 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package ppapi
     6  
     7  import (
     8  	"errors"
     9  	"fmt"
    10  )
    11  
    12  var (
    13  	ppErrors = map[Error]error{
    14  		/**
    15  		 * This value is returned by a function on successful synchronous completion
    16  		 * or is passed as a result to a PP_CompletionCallback_Func on successful
    17  		 * asynchronous completion.
    18  		 */
    19  		PP_OK: nil,
    20  		/**
    21  		 * This value is returned by a function that accepts a PP_CompletionCallback
    22  		 * and cannot complete synchronously. This code indicates that the given
    23  		 * callback will be asynchronously notified of the final result once it is
    24  		 * available.
    25  		 */
    26  		PP_OK_COMPLETIONPENDING: errors.New("ok: completion pending"),
    27  		/**This value indicates failure for unspecified reasons. */
    28  		PP_ERROR_FAILED: errors.New("failed"),
    29  		/**
    30  		 * This value indicates failure due to an asynchronous operation being
    31  		 * interrupted. The most common cause of this error code is destroying a
    32  		 * resource that still has a callback pending. All callbacks are guaranteed
    33  		 * to execute, so any callbacks pending on a destroyed resource will be
    34  		 * issued with PP_ERROR_ABORTED.
    35  		 *
    36  		 * If you get an aborted notification that you aren't expecting, check to
    37  		 * make sure that the resource you're using is still in scope. A common
    38  		 * mistake is to create a resource on the stack, which will destroy the
    39  		 * resource as soon as the function returns.
    40  		 */
    41  		PP_ERROR_ABORTED: errors.New("aborted"),
    42  		/** This value indicates failure due to an invalid argument. */
    43  		PP_ERROR_BADARGUMENT: errors.New("bad argument"),
    44  		/** This value indicates failure due to an invalid PP_Resource. */
    45  		PP_ERROR_BADRESOURCE: errors.New("bad resource"),
    46  		/** This value indicates failure due to an unavailable PPAPI interface. */
    47  		PP_ERROR_NOINTERFACE: errors.New("no interface"),
    48  		/** This value indicates failure due to insufficient privileges. */
    49  		PP_ERROR_NOACCESS: errors.New("access denied"),
    50  		/** This value indicates failure due to insufficient memory. */
    51  		PP_ERROR_NOMEMORY: errors.New("out of memory"),
    52  		/** This value indicates failure due to insufficient storage space. */
    53  		PP_ERROR_NOSPACE: errors.New("out of space"),
    54  		/** This value indicates failure due to insufficient storage quota. */
    55  		PP_ERROR_NOQUOTA: errors.New("quota exhausted"),
    56  		/**
    57  		 * This value indicates failure due to an action already being in
    58  		 * progress.
    59  		 */
    60  		PP_ERROR_INPROGRESS: errors.New("operation already in progress"),
    61  		/**
    62  		 * The requested command is not supported by the browser.
    63  		 */
    64  		PP_ERROR_NOTSUPPORTED: errors.New("operation not supported"),
    65  		/**
    66  		 * Returned if you try to use a null completion callback to "block until
    67  		 * complete" on the main thread. Blocking the main thread is not permitted
    68  		 * to keep the browser responsive (otherwise, you may not be able to handle
    69  		 * input events, and there are reentrancy and deadlock issues).
    70  		 */
    71  		PP_ERROR_BLOCKS_MAIN_THREAD: errors.New("operation would block the main thread"),
    72  		/** This value indicates failure due to a file that does not exist. */
    73  		PP_ERROR_FILENOTFOUND: errors.New("file not found"),
    74  		/** This value indicates failure due to a file that already exists. */
    75  		PP_ERROR_FILEEXISTS: errors.New("file exists"),
    76  		/** This value indicates failure due to a file that is too big. */
    77  		PP_ERROR_FILETOOBIG: errors.New("file too big"),
    78  		/**
    79  		 * This value indicates failure due to a file having been modified
    80  		 * unexpectedly.
    81  		 */
    82  		PP_ERROR_FILECHANGED: errors.New("file changed"),
    83  		/** This value indicates that the pathname does not reference a file. */
    84  		PP_ERROR_NOTAFILE: errors.New("not a file"),
    85  		/** This value indicates failure due to a time limit being exceeded. */
    86  		PP_ERROR_TIMEDOUT: errors.New("operation timed out"),
    87  		/**
    88  		 * This value indicates that the user cancelled rather than providing
    89  		 * expected input.
    90  		 */
    91  		PP_ERROR_USERCANCEL: errors.New("operation was canceled by the user"),
    92  		/**
    93  		 * This value indicates failure due to lack of a user gesture such as a
    94  		 * mouse click or key input event. Examples of actions requiring a user
    95  		 * gesture are showing the file chooser dialog and going into fullscreen
    96  		 * mode.
    97  		 */
    98  		PP_ERROR_NO_USER_GESTURE: errors.New("no user gesture"),
    99  		/**
   100  		 * This value indicates that the graphics context was lost due to a
   101  		 * power management event.
   102  		 */
   103  		PP_ERROR_CONTEXT_LOST: errors.New("graphics context was lost"),
   104  		/**
   105  		 * Indicates an attempt to make a PPAPI call on a thread without previously
   106  		 * registering a message loop via PPB_MessageLoop.AttachToCurrentThread.
   107  		 * Without this registration step, no PPAPI calls are supported.
   108  		 */
   109  		PP_ERROR_NO_MESSAGE_LOOP: errors.New("no message loop"),
   110  		/**
   111  		 * Indicates that the requested operation is not permitted on the current
   112  		 * thread.
   113  		 */
   114  		PP_ERROR_WRONG_THREAD: errors.New("operation is not permitted on the current thread"),
   115  		/**
   116  		 * This value indicates that the connection was closed. For TCP sockets, it
   117  		 * corresponds to a TCP FIN.
   118  		 */
   119  		PP_ERROR_CONNECTION_CLOSED: errors.New("connection closed"),
   120  		/**
   121  		 * This value indicates that the connection was reset. For TCP sockets, it
   122  		 * corresponds to a TCP RST.
   123  		 */
   124  		PP_ERROR_CONNECTION_RESET: errors.New("connection reset"),
   125  		/**
   126  		 * This value indicates that the connection attempt was refused.
   127  		 */
   128  		PP_ERROR_CONNECTION_REFUSED: errors.New("connection refused"),
   129  		/**
   130  		 * This value indicates that the connection was aborted. For TCP sockets, it
   131  		 * means the connection timed out as a result of not receiving an ACK for data
   132  		 * sent. This can include a FIN packet that did not get ACK'd.
   133  		 */
   134  		PP_ERROR_CONNECTION_ABORTED: errors.New("connection aborted"),
   135  		/**
   136  		 * This value indicates that the connection attempt failed.
   137  		 */
   138  		PP_ERROR_CONNECTION_FAILED: errors.New("connection failed"),
   139  		/**
   140  		 * This value indicates that the connection attempt timed out.
   141  		 */
   142  		PP_ERROR_CONNECTION_TIMEDOUT: errors.New("connection timed out"),
   143  		/**
   144  		 * This value indicates that the IP address or port number is invalid.
   145  		 */
   146  		PP_ERROR_ADDRESS_INVALID: errors.New("invalid address"),
   147  		/**
   148  		 * This value indicates that the IP address is unreachable. This usually means
   149  		 * that there is no route to the specified host or network.
   150  		 */
   151  		PP_ERROR_ADDRESS_UNREACHABLE: errors.New("address unreachable"),
   152  		/**
   153  		 * This value is returned when attempting to bind an address that is already
   154  		 * in use.
   155  		 */
   156  		PP_ERROR_ADDRESS_IN_USE: errors.New("address in use"),
   157  		/**
   158  		 * This value indicates that the message was too large for the transport.
   159  		 */
   160  		PP_ERROR_MESSAGE_TOO_BIG: errors.New("message too big"),
   161  		/**
   162  		 * This value indicates that the host name could not be resolved.
   163  		 */
   164  		PP_ERROR_NAME_NOT_RESOLVED: errors.New("name can't be resolved"),
   165  	}
   166  )
   167  
   168  func decodeError(code Error) error {
   169  	err, ok := ppErrors[code]
   170  	if ok {
   171  		return err
   172  	}
   173  	return fmt.Errorf("unknown ppapi error %d", code)
   174  }