forked from Shinmera/cl-steamworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditions.lisp
109 lines (84 loc) · 4.09 KB
/
conditions.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#|
This file is a part of cl-steamworks
(c) 2019 Shirakumo http://tymoon.eu ([email protected])
Author: Nicolas Hafner <[email protected]>
|#
(in-package #:org.shirakumo.fraf.steamworks)
(define-condition steamworks-condition (condition)
())
(defmacro define-simple-condition (name direct-superclasses format-string &rest format-args)
(let ((condition (gensym "CONDITION"))
(stream (gensym "STREAM")))
`(define-condition ,name (,@direct-superclasses steamworks-condition)
,(loop for arg in format-args
for (name . default) = (if (listp arg) arg (list arg))
for initarg = (intern (string name) "KEYWORD")
collect (list name
:initarg initarg
:initform (if default
(car default)
`(error 'argument-missing :argument ',initarg))
:reader name))
(:report (lambda (,condition ,stream)
(format ,stream ,format-string
,@(loop for arg in format-args
collect `(,(if (listp arg) (car arg) arg) ,condition))))))))
(define-simple-condition argument-missing (error)
"The argument ~s is required, but was not passed."
argument)
(define-simple-condition api-call-failed (error)
"The SteamWorks API call ~@[~% ~s~%~]did not succeed~:[ for an unknown reason.~;: ~:*~a~]"
(api-call NIL) (error-code NIL))
(define-simple-condition string-too-long (error)
"The string~% ~s~%is too long.~@[ The API has a limit of ~s UTF-8 octets.~]"
oversized-string (octet-limit NIL))
(define-simple-condition no-such-callback (error)
"There is no callback named ~s."
callback-name)
(define-simple-condition no-such-file (file-error)
"The file~% ~a~%does not exist."
file-handle)
(define-simple-condition no-such-user (error)
"The user~% ~a~%does not exist."
user-handle)
(define-simple-condition buffer-too-short (error)
"The buffer needs to be able to hold at least ~d bytes."
required-bytes)
(define-simple-condition voice-data-corrupted (warning)
"The voice data was corrupted and has been lost.")
(define-simple-condition interface-creation-failed (error)
"Failed to create a handle ~:[for an interface.~;~:*to the ~a interface~]."
(interface-name NIL))
(define-simple-condition not-an-image-file (error)
"The given file ~a does not appear to be an image (PNG, JPG, GIF, SVG) file."
file-handle)
(define-simple-condition string-malformed (error)
"The string~% ~s~%contains invalid characters."
malformed-string)
(define-simple-condition pathname-not-a-directory (error)
"The pathname~% ~a~%does not designate a directory."
file-handle)
(define-simple-condition too-many-requests (error)
"The function call would incur too many requests.~@[ The limit is at ~d~]"
(request-limit NIL))
(define-simple-condition workshop-agreement-not-accepted (warning)
"The user has not yet accepted the Steam Workshop agreement.")
(define-simple-condition file-seeking-impossible (error)
"Cannot seek when reading the entire file.")
(define-simple-condition request-denied (error)
"You do not have permission to perform the request.")
(define-simple-condition cannot-set-member-data-for-others (request-denied)
"You cannot set the member data for users other than the local user.")
(define-simple-condition steamworks-not-initialized (error)
"The SteamWorks API has not yet been initialized.")
(define-simple-condition steamworks-already-initialized (error)
"The SteamWorks API has already been initialized before.")
(define-simple-condition initialization-failed (api-call-failed)
"SteamWorks initialization failed.
Is Steam running and the app-id set up properly?")
(define-simple-condition user-stats-not-ready (warning)
"The stats for the current user have been requested but are not yet ready.
You might need to call (run-callbacks T)")
(define-simple-condition low-level-not-loaded (error)
"The low-level file is not present.
Please follow the instructions in the documentation to set up this library properly.")