ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
src/web/common/errors.c
Go to the documentation of this file.
1#include "errors.h"
3#include <libplatform/thread.h>
5#include <ascii-chat/source_root.h>
6#include <emscripten/emscripten.h>
7
9static size_t browser_error_count;
10
12 asciichat_errno_snapshot_t snapshot = errno_snapshot(thread_current_id(), browser_error_frames, ASCIICHAT_ERRNO_MAX_DEPTH);
13 browser_error_count = snapshot.copied;
14 return snapshot.total;
15}
16
17static const asciichat_error_context_t *browser_error_at(size_t index) {
18 return index < browser_error_count ? &browser_error_frames[index] : NULL;
19}
20
22 const asciichat_error_context_t *frame = browser_error_at(index);
23 return frame ? frame->code : ASCIICHAT_OK;
24}
25
26const char *browser_error_message(size_t index) {
27 const asciichat_error_context_t *frame = browser_error_at(index);
28 return frame ? frame->context_message : "";
29}
30
31const char *browser_error_file(size_t index) {
32 const asciichat_error_context_t *frame = browser_error_at(index);
33 return frame && frame->file ? extract_project_relative_path(frame->file, ASCIICHAT_OWNED_SOURCE_DIRS) : "";
34}
35
36const char *browser_error_full_file(size_t index) {
37#ifdef NDEBUG
38 (void)index;
39 return "";
40#else
41 const asciichat_error_context_t *frame = browser_error_at(index);
42 return frame && frame->file ? frame->file : "";
43#endif
44}
45
46const char *browser_error_function(size_t index) {
47 const asciichat_error_context_t *frame = browser_error_at(index);
48 return frame && frame->function ? frame->function : "";
49}
50
52 const asciichat_error_context_t *frame = browser_error_at(index);
53 return frame ? frame->line : 0;
54}
55
58 browser_error_count = 0;
59}
void errno_clear_all(void)
asciichat_errno_snapshot_t errno_snapshot(uint64_t id, asciichat_error_context_t *out, size_t capacity)
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
#define ASCIICHAT_ERRNO_MAX_DEPTH
@ ASCIICHAT_OK
Definition error_codes.h:50
const char * extract_project_relative_path(const char *file, const char *const *owned_dirs)
Extract a path relative to the source root embedded by CMake.
Definition path.c:137
📂 Path Manipulation Utilities
static bool size_t index
Definition queries.h:10
int browser_error_code(size_t index)
const char * browser_error_message(size_t index)
const char * browser_error_function(size_t index)
void browser_error_dismiss(void)
size_t browser_error_snapshot(void)
const char * browser_error_full_file(size_t index)
const char * browser_error_file(size_t index)
int browser_error_line(size_t index)