Function SDK
Errors and limits
WispError, storage quota errors, and the platform's limits for functions, storage and requests.
#WispError
SDK methods throw WispError for problems your code can act on — a missing required setting, an invalid key or path, a full storage quota.
import { kv, WispError } from 'wisp';
try {
await kv.set('big', hugeValue);
} catch (err) {
if (err instanceof WispError) return { status: 400, body: { error: err.message } };
throw err;
}from wisp import kv, WispError
try:
kv.set("big", huge_value)
except WispError as e:
return {"status": 400, "body": {"error": str(e)}}Uncaught errors return 500 to the caller and are recorded with their stack trace in the log.
#Storage is full
When the workspace is over its storage quota with no storage credits, writes (kv.set, kv.incr, table.insert/put/update, file.write) throw a WispError whose message starts with Storage is full. Reads and deletes keep working.
#Status codes from Wisp
| Status | When |
|---|---|
401 | The project requires an API key and none, an invalid or an expired one was sent |
402 | The workspace is out of Run credits |
404 | No such function, or the project isn't published yet (use ?test) |
405 | The method doesn't match the function's |
429 | A rate limit was reached |
500 | Your code threw an error or ran longer than the time limit (details in the log) |
#Limits
| Limit | Value |
|---|---|
| Run time | 15 seconds per request |
| Memory | 256 MB |
| Request and response | 6 MB |
| Key-value | keys 512 bytes, values 256 KB, 1,000 per list page |
| Table rows | 256 KB; find/count scan up to 10,000 rows |
| Files | 25 MB; paths up to 1,024 bytes |
| Schedules | at most every 5 minutes |
| Logged bodies | first 2,000 characters |