Skip to content

Commit

Permalink
Tidying up error messages (no trailing '.' or '\n'), making almost-si…
Browse files Browse the repository at this point in the history
…milar error messages the same

Used the following to try and find issues:

find . -name "*.c" | xargs -I{} grep -h jsExceptionHere {} | sed -e "s/^[^\"]*\"/\"/" | sort | uniq -c
  • Loading branch information
gfwilliams committed Oct 6, 2023
1 parent bbb6c89 commit 4327ebd
Show file tree
Hide file tree
Showing 42 changed files with 351 additions and 350 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
nRF52: bootloader asks for connection interval 7.5->30ms now, not just 15ms. Should improve DFU on iOS 16 which doesn't honour 15ms request
Fix unicode in object keys when UTF8 support enabled, eg. {'\u00e4':1}
Bangle.js: Change order of items in the Recovery Menu (hold BTN at boot) to put more common options first
Tidying up error messages (no trailing '.' or '\n'), making almost-similar error messages the same

2v19 : Fix Object.values/entries for numeric keys after 2v18 regression (fix #2375)
nRF52: for SD>5 use static buffers for advertising and scan response data (#2367)
Expand Down
4 changes: 2 additions & 2 deletions libs/bluetooth/jswrap_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ Booting your device while holding all buttons down together should also have the
void jswrap_ble_eraseBonds() {
#if PEER_MANAGER_ENABLED
if (jsble_has_connection()) {
jsExceptionHere(JSET_ERROR, "BLE Connected, can't erase bonds.\n");
jsExceptionHere(JSET_ERROR, "BLE Connected, can't erase bonds.");
} else {
jsble_central_eraseBonds();
}
Expand Down Expand Up @@ -2064,7 +2064,7 @@ void jswrap_ble_setScan(JsVar *callback, JsVar *options) {
return;
}
} else if (options)
jsExceptionHere(JSET_TYPEERROR, "Expecting Object got %t\n", options);
jsExceptionHere(JSET_TYPEERROR, "Expecting Object got %t", options);
// set the callback event variable
if (!jsvIsFunction(callback)) callback=0;
if (callback) {
Expand Down
18 changes: 9 additions & 9 deletions libs/filesystem/jswrap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool isSdSPISetup();
// 'path' must be of JS_DIR_BUF_SIZE
bool jsfsGetPathString(char *pathStr, JsVar *path) {
if (jsvGetString(path, pathStr, JS_DIR_BUF_SIZE)==JS_DIR_BUF_SIZE) {
jsExceptionHere(JSET_ERROR, "File path too long\n");
jsExceptionHere(JSET_ERROR, "File path too long");
return false;
}
return true;
Expand Down Expand Up @@ -71,10 +71,10 @@ void jsfsReportError(const char *msg, FRESULT res) {
}

bool jsfsInit() {

#ifndef LINUX
if (!fat_initialised) {
#ifndef USE_FLASHFS
#ifndef USE_FLASHFS
#ifdef SD_CARD_ANYWHERE
if (!isSdSPISetup()) {
#ifdef SD_SPI
Expand All @@ -95,7 +95,7 @@ bool jsfsInit() {
#endif // SD_SPI
}
#endif // SD_CARD_ANYWHER
#endif // USE_FLASHFS
#endif // USE_FLASHFS
FRESULT res;

if ((res = f_mount(&jsfsFAT, "", 1)) != FR_OK) {
Expand Down Expand Up @@ -147,7 +147,7 @@ initialised, and some cards will not work reliably without one.
void jswrap_E_connectSDCard(JsVar *spi, Pin csPin) {
#ifdef SD_CARD_ANYWHERE
if (!jsvIsObject(spi)) {
jsExceptionHere(JSET_ERROR, "First argument is a %t, not an SPI object\n", spi);
jsExceptionHere(JSET_ERROR, "First argument is a %t, not an SPI object", spi);
return;
}
if (!jshIsPinValid(csPin)) {
Expand Down Expand Up @@ -557,9 +557,9 @@ Seek to a certain position in the file
*/
void jswrap_file_skip_or_seek(JsVar* parent, int nBytes, bool is_skip) {
if (nBytes<0) {
if ( is_skip )
if ( is_skip )
jsWarn("Bytes to skip must be >=0");
else
else
jsWarn("Position to seek to must be >=0");
return;
}
Expand Down Expand Up @@ -655,7 +655,7 @@ int jswrap_E_flashFatFS(JsVar* options) {
else if (!jsvIsUndefined(options)) {
jsExceptionHere(JSET_TYPEERROR, "'options' must be an object, or undefined");
}

uint8_t init=flashFatFsInit(addr, sectors);
if (init) {
if ( format ) {
Expand All @@ -666,7 +666,7 @@ int jswrap_E_flashFatFS(JsVar* options) {
jsExceptionHere(JSET_INTERNALERROR, "Flash Formatting error:",res);
return false;
}
}
}
}
jsfsInit();
return true;
Expand Down
2 changes: 1 addition & 1 deletion libs/graphics/font/fontconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
file, You can obtain one at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------------------------------------
Bitmap font creator for Graphics custom fonts
Bitmap font creator for Espruino Graphics custom fonts
Takes input as a PNG font map, PBFF, or bitfontmaker2 JSON
Expand Down
2 changes: 1 addition & 1 deletion libs/graphics/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ bool graphicsSetCallbacks(JsGraphics *gfx) {
lcd_spi_unbuf_setCallbacks(gfx);
#endif
} else {
jsExceptionHere(JSET_INTERNALERROR, "Unknown graphics type\n");
jsExceptionHere(JSET_INTERNALERROR, "Unknown graphics type");
assert(0);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/graphics/jswrap_graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,11 @@ JsVar *jswrap_graphics_createArrayBuffer(int width, int height, int bpp, JsVar *
if (gfx.data.bpp==1)
gfx.data.flags = (JsGraphicsFlags)(gfx.data.flags | JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE);
else {
jsExceptionHere(JSET_ERROR, "vertical_byte only works for 1bpp ArrayBuffers\n");
jsExceptionHere(JSET_ERROR, "vertical_byte only works for 1bpp ArrayBuffers");
return 0;
}
if (gfx.data.height&7) {
jsExceptionHere(JSET_ERROR, "height must be a multiple of 8 when using vertical_byte\n");
jsExceptionHere(JSET_ERROR, "height must be a multiple of 8 when using vertical_byte");
return 0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions libs/graphics/lcd_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void lcdSetPixel_SDL(JsGraphics *gfx, int x, int y, unsigned int col) {

void lcdInit_SDL(JsGraphics *gfx) {
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) {
jsExceptionHere(JSET_ERROR, "SDL_Init failed\n");
jsExceptionHere(JSET_ERROR, "SDL_Init failed");
exit(1);
}
if (!(screen = SDL_SetVideoMode(gfx->data.width, gfx->data.height, 32, SDL_SWSURFACE)))
{
jsExceptionHere(JSET_ERROR, "SDL_SetVideoMode failed\n");
jsExceptionHere(JSET_ERROR, "SDL_SetVideoMode failed");
SDL_Quit();
exit(1);
}
Expand Down
16 changes: 8 additions & 8 deletions libs/neopixel/jswrap_neopixel.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ multiple of 3 bytes long. Just round the size up - it won't cause any problems.
* On some platforms like STM32, pins capable of hardware SPI MOSI are required.
* On STM32, `neopixel.write` chooses a hardware SPI device to output the signal on
and uses that. However in order to avoid spikes in the output, if that hardware device is *already
initialised* it will not be re-initialised. This means that if the SPI device was already in use,
and uses that. However in order to avoid spikes in the output, if that hardware device is *already
initialised* it will not be re-initialised. This means that if the SPI device was already in use,
you may have to use `SPIx.setup({baud:3200000, mosi:the_pin})` to force it to be re-setup on the pin.
* Espruino devices tend to have 3.3v IO, while WS2812/etc run off of 5v. Many
Expand All @@ -116,11 +116,11 @@ void jswrap_neopixel_write(Pin pin, JsVar *data) {
return;
}
if (rgbSize == 0) {
jsExceptionHere(JSET_ERROR, "Data must be a non empty array.");
jsExceptionHere(JSET_ERROR, "Data must be a non empty array");
return;
}
if (rgbSize % 3 != 0) {
jsExceptionHere(JSET_ERROR, "Data length must be a multiple of 3 (RGB).");
jsExceptionHere(JSET_ERROR, "Data length must be a multiple of 3 (RGB)");
return;
}

Expand All @@ -145,7 +145,7 @@ extern Pin jshNeoPixelPin; ///< The currently setup Neopixel pin (set by jswrap_
// this one could potentially work on other platforms as well...
bool neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize) {
if (!jshIsPinValid(pin)) {
jsExceptionHere(JSET_ERROR, "Pin is not valid.");
jsExceptionHere(JSET_ERROR, "Pin is not valid");
return false;
}
JshPinFunction spiDevice = 0;
Expand All @@ -158,7 +158,7 @@ bool neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize) {
}
IOEventFlags device = jshGetFromDevicePinFunction(spiDevice);
if (!spiDevice || !device) {
jsExceptionHere(JSET_ERROR, "No suitable SPI device found for this pin\n");
jsExceptionHere(JSET_ERROR, "No suitable SPI device found for this pin");
return false;
}
JshSPIInfo inf;
Expand Down Expand Up @@ -187,7 +187,7 @@ bool neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize) {
bool neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize) {
#ifdef NRF52_SERIES
if (!jshIsPinValid(pin)) {
jsExceptionHere(JSET_ERROR, "Pin is not valid.");
jsExceptionHere(JSET_ERROR, "Pin is not valid");
return false;
}
return !i2s_ws2812b_drive_xfer((rgb_led_t *)rgbData, rgbSize/3, pinInfo[pin].pin);
Expand All @@ -208,7 +208,7 @@ static inline uint32_t _getCycleCount(void) {

bool neopixelWrite(Pin pin, unsigned char *rgbData, size_t rgbSize) {
if (!jshIsPinValid(pin)) {
jsExceptionHere(JSET_ERROR, "Pin is not valid.");
jsExceptionHere(JSET_ERROR, "Pin is not valid");
return false;
}
if (!jshGetPinStateIsManual(pin))
Expand Down
2 changes: 1 addition & 1 deletion libs/network/cc3000/network_cc3000.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool net_cc3000_checkError(JsNetwork *net) {
if (wlan) {
jswrap_wlan_reconnect(wlan);
jsvUnLock(wlan);
} else jsExceptionHere(JSET_INTERNALERROR, "No CC3000 object!\n");
} else jsExceptionHere(JSET_INTERNALERROR, "No CC3000 object!");
// jswrap_wlan_reconnect could fail, which would mean we have to do this all over again
}
return hadErrors;
Expand Down
Loading

0 comments on commit 4327ebd

Please sign in to comment.